DirectButton not work with foriegn characters?

I am making my game multi-lingual, however when I send a phrase of text to a DirectGUI widget (In this case, a DirectButton), I get random letters and symbols back. I’ve tested, the problem is not with my language file, it works fine in console. Perhaps I need to change font? (I’m using the default right now)

It should just work if you send a Python unicode object (instead of a string object). Python unicode objects are designed for holding international characters without having to deal with encoding issues.

If you’re not familiar with Python unicode objects, and you’re instead using a string object to hold international characters directly, then you have to tell Panda which encoding you’re using. Try one of:

text-encoding iso8859

or

text-encoding utf-8

in your Config.prc file.

It might be worth reading up on Python unicode objects, though. Python has this whole system for dealing with international characters and the encoding issues that always arise with them, and it works pretty well.

David

I edited my PRC file accordingly, using both encodings you gave me and got no difference.

Well, which encoding are you using? I mean in your Python source file. In order to store characters other than ASCII characters, you have to save the file with some specific encoding. Which one did you use?

David

I am using UTF-8, but when I set the config file to that, nothing changed. I was using the Spanish lowercase letter ‘n’ with a squiggly over it (ASCII code 164), but instead I get an uppercase letter ‘A’ with a squiggly over it next to a ‘plus-or-minus sign’.(You know, the one with a plus on top of a minus…)

Oh, whoops, I told you wrong. The correct string is:

text-encoding utf8

Note the lack of a hyphen. You should have seen an error message about the unrecognized string “utf-8”; didn’t it display an error message in the output log?

If that still doesn’t work, you must be editing the wrong config file. Try this. In Python, type the commands:

>>> from direct.directbase.DirectStart import *
>>> print cpMgr

this will display the list of config files Panda has loaded. Make sure the file you’ve edited is on that list. Also try:

>>> print ConfigVariableString('text-encoding')

this will display the current value of the text-encoding config variable. Make sure it contains the “utf8” string you assigned to it.

David

Thanks, this fixed it!