How to convert a string from UTF8 to BIG5?
#1
could anyone tell me the way to convert a string from utf8 to big5? an unknown encoding exception is catched with the following script.

mystring.encode('big5hkscs')

thanks in advance.
Reply
#2
googled result maybe will help?
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#3
thanks for your help. i have no problem with converting strings from big5 to utf8, however, i can't convert strings from utf8 to big5.

as i know, python 2.4 should support big5hkscs...  Sad
the encode function is working fine on my pc with python 2.4.2, i just can't make it on xbmc.



Reply
#4
i still couldn't find out the answer. Sad

i am trying to write a script that read the id3v2 info from the playing file. i used the function xbmc.player().getplayingfile() to get the filename, and it returns the filename in utf8. (it returns the filename in user selected encoding on build 17-04-2006).

i tried to run the script to encode a string from utf8 to big5 on my pc with python 2.4.3 and it works fine. however, it throws lookuperror when i run it on xbmc.

should i somehow register the codecs at the beginning of my script? could you give me an idea?

thanks a lot!
:bowdown:
Reply
#5
i did some research on this problem and still couldn't find out the answer. also, it seems like guessing the original charset is not a good choice.

other than converting a string from utf8 to big5, is there any way to make the function call xbmc.player().getplayingfile() to return a filename with its original charset? is there anything to do with the xbmc settings?

please help... Image
Reply
#6
can you compile your own xbmc?

i'm not sure i understand correctly, but the method you're referring to returns a string.

are you saying the string returned doesn't have the correct charecters in it.

the following is a replacement for that method that returns a unicode. is this what you need?

maybe a developer would have to answer this question and say if a unicode is what's needed?

the commented out line is what was replaced with the other lines.

if you can compile this is in player.cpp under /libpython/

Quote: cstdstringw unicodelabel;
g_charsetconverter.utf8toutf16(g_application.currentfile().c_str(), unicodelabel);
return py_buildvalue("u", unicodelabel.c_str());
//return py_buildvalue("s", g_application.currentfile().c_str());
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#7
thanks for your reply. Smile

i can't compile xbmc myself, i just download it from the internet.

actually, the method xbmc.player().getplayingfile() does returns filenames in unicode. however, some of the files in my xbox are stored with filenames in big5. to open the playing file, i'll need the original characters of the filename. as the method call returns unicode filenames, i just couldn't open those files based on the returned filename.
Reply
#8
ok, i completely don't understand. Smile

there is a setting in appearance for character set. i have no idea if this effects python or if it's what you need?
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#9
oh... sorry about my english, as i'm not a native.

let me try to make my question clear.

as i would like to open the playing media file, which is stored in my xbox with filename encoded in big5, i needed to get the filename with the method xbmc.player().getplayingfile(). the method returns the exact characters of the filename before the version 2006-04-17. however, the function returns a converted filename (in utf8) after version 2006-04-17.

i can't open the file with the converted filename, as the filesystem couldn't find it. i'll need the original filename to open it.

i think the behavior of the method is ok for ui, but it brings me another problem on file operation.
Reply
#10
is that possible to add a method to the player class that returns the playing filename without converting the charset? this function is needed for file operations.
Reply

Logout Mark Read Team Forum Stats Members Help
How to convert a string from UTF8 to BIG5?0