[solved] Cyrillic characters
I wrote simple script based on this post: http://forum.cogsci.nl/index.php?p=/discussion/469/open-selective-sampling-with-a-ratio-help-please/p1 (many thanks
)
But my script's outcome is squares. I use Cyrillic characters. I've read forum's post about Farsi, but I don't want use PyGame back-end. I'd prefer PsychoPy. Can you help me?
Here the link on archive with script and files http://www.filedropper.com/word_1
Comments
Hi,
In principle, you should be able to use Cyrillic text without any problems, because (unlike Farsi, which is a whole different story) Cyrillic is part of most standard fonts. However, I noticed that under Windows 7 you see only question marks. I imagine that's what you get as well, right?
I'm not completely sure what the underlying problem is, but it has something to do with how OpenSesame represents text internally, which apparently depends on the operating system. For now, you'll have to work around it.
The easy-but-not-so-convenient way
You could create bitmaps for all your text, and present them like that. This will of course solve all font-related issues, but it might be very inconvenient.
The clever way
You could save your Cyrillic words in separate text files and read them into OpenSesame at runtime. This way they are not part of the experiment script, and do not suffer from the encoding issue. For example, the following script reads text from a file and sets it as the variable
[word]. You can then use this variable to show text in a sketchpad, just like you normally would.The exact way to go about this depends on your experiment, of course, and you'll have to use a bit of Python (but nothing too complicated).
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
@sebastiaan Thank you for response, but "clever way" is exactly what I am doing in my script. And it doesn't work. By the way if I write Cyrillic text in sketchpad it's work:
but if I use your script and:
it shows question marks.
So maybe it's Python related problems? (I use opensesame_0.27.3~pre1-win32-1 and Windows XP / Windows 7)
Ok, well you're getting into messy character-encoding territory here ... I don't have a full grasp on it myself (otherwise I would've have fixed it in OpenSesame), but I can give you some tips for this specific case.
The first thing is to realize that not all files are created equal: Text files have a specific character encoding, in your case Windows-1251, or
cp1251as Python calls it. Therefore, when you read this data in, you have to tell Python what the encoding is, otherwise it won't work.Like so:
You may want to take a look at this page, which outlines the (subtle) difference between the Python
unicodeandstrobjects:Check out SigmundAI.eu for our OpenSesame AI assistant!
Yes, it's working. Thanks.