Text Stimuli in other language

Hey there,

Is it impossible to code text stimuli in languages requiring other characters than the ones in english language (e.g. text stimuli containing ‘é’ or ‘ç’, etc.) ?? What do I need to do to make that possible / How do I need to adapt my stimuli written for example in french to avoid errors?

Never mind, found it out; place a u in front, sorry

Also consider using the “Python 3” version of PsychoPy. Python 3 handles unicode text better than Python 2, and in Python 3, all strings are unicode, so we no longer need the u prefix.

I just checked that and my scripts created with psychopy 2 run perfectly. First, there shouldn’t be a problem running scripts created in psychopy 2 on the python 3 version right? timing etc. everything stays the same? I ask that because I don’t really know what’s new in the python 3 version, given that I always worked with the python 2 version…

Then, another question. I got now that I don’t need to put the “u” in front of the texts to display them written correctly. However, I created a script (with python as well) which analyses the .csv output of psychopy. Is there some way to make that the output of the text stimulus “lié” is truly “lié” in the csv output and not the word coded in unicode? Or do you may know what I need to do that my data analysis program written in python recognizes the stimulus as “lié”?

in my analysis script written in python, imagine the line (simplified, I’m just wondering what I need to write after the “==”):

if word == "lié": add data

Found something. Is that the best solution?

The first line of my actual program is:
data = open('/Users/me/Desktop/Folder/file.csv','r')

I changed it to:

f = codecs.open('/Users/me/Desktop/Folder/file.csv', encoding='utf-8')

Also: How do I convert the results back into text such that I can write data into a txt file?
When I try to write down my results in a txt file, it gives me a unicode encode error and writes nothing into the txt Results file:

UnicodeEncodeError: 'ascii' codec can't encode character '\xce' in position 8: ordinal not in range(128)

Yes, all of that stuff is the same. There is only one codebase for PsychoPy, and we currently do our best to make it compatible with both Python 2 and 3. Eventually the Python 2 support will be dropped.

That script should ideally be running under Python 3 as well. People here would need to see some of your actual code to give advice on what to do (I’m not an expert on this stuff myself).

Again, we would need to see your actual code and know what version of Python you are using. But you should probably explicitly specify that encoding=“utf-8”.

All good now thanks, it seems to work with the codecs module!

Cheers!