Encode exception for chinese text

Vinayakc vinayakchitre at gmail.com
Fri May 19 07:03:47 EDT 2006


Hi all,

I am new to python.

I have written one small application which reads data from xml file and
tries to encode data using apprpriate charset.
I am facing problem while encoding one chinese paragraph with charset
"gb2312".

code is:

encoded_str = str_data.encode("gb2312")

The type of str_data is <type 'unicode'>

The exception is:

"UnicodeEncodeError: 'gb2312' codec can't encode character u'\xa0' in
position 0: illegal multibyte sequence"

Can anyone please give me direction to solve this isssue.

Regards,
Vinayakc




More information about the Python-list mailing list