i18n pot file

Martin v. Löwis martin at v.loewis.de
Sun Nov 2 19:41:14 CET 2003


"anabell" <anabell at sh163a.sta.net.cn> writes:

> I was unable to use charset utf-8 because I get this error message when I
> try to run my localized application:
> 
> UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-1: invalid
> data

That is because your PO file is not coded in UTF-8, but, apparently, in
gb2312.

> I wonder though how I can make utf-8 work if it does support any language.

That should be possible.

> I looked into my python23/lib/encodings/ and found there exist utf-8.  I
> edited my .po file to charset utf_8, and generated its .mo file.  But when I
> ran my localized application, python's gettext module can recognize the
> charset 'utf8', but problem occurs when it starts decoding the .mo file.

You can't simply change the encoding - you also need to make sure the
encoding is *correct*. I.e. all messages need to be in UTF-8, not in
gb2312. Merely changing the Content-Type does not change any of your
messages.

> I opened the utf_8.py codec file, and found no character map.  I wonder if
> it's using a wrong map?

No. Encoding of UTF-8 works without a map. Instead, there is a C
function implementing UTF-8.

Regards,
Martin




More information about the Python-list mailing list