| Reference | Downloads | Github

Textbox input Unicode issue

OS (e.g. Win10): MacOS 10.13.6
PsychoPy version (e.g. 1.84.x): v2020.2.5
Standard Standalone? (y/n) If not then what?: Y
What are you trying to achieve?:
Use new textinput Response function with Korean, Japanese, and Indian Input.

What did you try to make it work?:
Without font support, just blank box appears. After select proper font, the typed input string shows up in experiment screen. However, it cannot be saved, and the experiment hangs when it finished and trying to save the result.

What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information.

It seems the old ‘unicode input error’. I mentioned before. I guess the only the English and other Ratin-based language is usable for textbox.

Traceback (most recent call last):
File "ctypes/callbacks.c", line 234, in ‘calling callback function’
File “/Applications/”, line 1121, in objc_method
result = f(py_self, *args)
File “/Applications/”, line 164, in pygletKeyUp

symbol = getSymbol(nsevent)
File “/Applications/”, line 52, in getSymbol
return charmap[chars[0].upper()]
KeyError: ‘\u315b’

I’m not quite clear what you mean by this (particularly as the error messages all refer to pyglet). Are you using the new TextBox2 stimulus to capture editable text automatically, or using the old approach, which required custom code, and the old TextStim class?

I am using textbox2 via builder GUI and facing the same problem
(the string input is visible with error log per every keypress), and the experiment freeze when it tries to save the result.

In your experiment settings, what formats are you saving in? If the text renders but won’t save then it may be that the unicode contents of the Textbox aren’t being stored properly in the .csv, .xlsx, etc. by whatever function is writing to those docs

The default csv setting.
I didn’t modified the save setting.

In that case it’s most likely that there’s something in the saveAsWideText function which uses some function which is incompatable with Koren characters… I’ll make some experiments to test this out to see where it breaks then get back to you!

I’m struggling to replicate this error - what characters and font did you use specifically? When I tried just now with the text 사이코 파이 (“PsychoPy” according to Google Translate) in Black Han Sans it saved just fine, so I’m guessing it’s either a specific character in your string or something to do with your font file

Hi, @TParsons,

Thank you for the investigation.
Are you using Windows or MacOS?
Since, as far as I know, MacOS use very strange Korean key input both OS level and Python backend of PsychoPy.

I use Windows 10, @Michael also raised that some Hindi characters don’t render in Textboxes on Mac too:

So I think you’re right that it’s something to do with how Macs handle key inputs.

I’ve added a test to our test suite to check that all unicode characters are saved correctly:

and that’s passing even on the Linux distro we run automatic testing on, so I’ll pass this to a Mac user and get them to try it out.