Hi Nunia,
There is a post on Hebrew text that should work for you as well.
In TextEdit, save your file as Plain Text with encoding UTF-8 and use decode() in NodeBox:
txt = open("chinese.txt").read() txt = txt.decode("utf-8") text(txt, 20, 20)
utf-8 is not working. throw error
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb2 in position 3: unexpected code byte
And i can't find any encoding name to replace 'utf8' for the life of me. I checked many unicode encoding tables on docs.python.org and couldn't figure out...
thanks tom. it works for me now. i followed your instruction using TextEdit to save my terminal vi editing file in EUC encoding as UTF-8 encoding...
i am quite content to get this working. I use your code example and then iPhoto for 12 sequence of .png files with slective iTune music and export to .mov. One thing though, iPhoto has this cool 'droplet' effect that is not exportable, it'll be cool to simulate 'droplet' effect in nodebox....
read from files of unicode char and display it in unicode
Posted by nunia on Jun 03, 2007I can't seem to get nodebox to work with reading from unicode Chinese character files. I can assign literal with u" prefix to string variable and work with them... But i can't find way to pass u" prefix to strings getting from object file's read() or readline() etc...
for example, in python command line with terminal 'Character Set' set to 'Simplified Chinese', I can do
>>> f = open('cncharfile.txt')
>>>print f.readline()
小 不 忍 而 乱 大 谋
In nodebox, I can only do:
ln1 = u"小 不 忍 而 乱 大 谋"
text(ln1,0,0)
I can't really display of Unicode character directly from file.read()
Is there a way ???