problem with cjkcodecs on Mandrake linux
Anthony Liu
antonyliu2002 at yahoo.com
Wed Mar 17 02:26:06 EST 2004
I've added
export LANG=zh_CN.GB2312
in both .bash_profile and .bashrc
Now, if I issue 'locale', I get:
LANG=zh_CN.GB2312
LC_CTYPE=en_US
LC_NUMERIC=en_US
LC_TIME=en_US
LC_COLLATE=en_US
LC_MONETARY=en_US
LC_MESSAGES=en_US
LC_PAPER=en_US
LC_NAME=en_US
LC_ADDRESS=en_US
LC_TELEPHONE=en_US
LC_MEASUREMENT=en_US
LC_IDENTIFICATION=en_US
LC_ALL=
Notice that LANG=zh_CN.GB2312, which seems to be what
I want, but still when I run the following script:
s = 'SomeChineseCharacter'
# don't take this literally, s is simply a string in
# the Chinese language
s = unicode(s, 'gb2312')
print s
I still get the same error message:
UnicodeEncodeError: 'latin-1' codec can't encode
characters in position 0-1: ordinal not in range(256).
What should I do? Thank you!
--- "Martin_v._Löwis" <martin at v.loewis.de> wrote:
> Anthony Liu wrote:
> > OK, gotcha. By the way, do you know how to set the
> > default language of Mandrake or any linux system,
> so
> > that I can probably mimic.
>
> You need to set the LANG environment variable. This
> is best done on a per-user basis, e.g. in the .login
> file of the user. Setting LANG to zh_CN should give
> you a (simplified) Chinese environment. Python 2.3
> will automatically pick up that setting when
> printing
> Unicode strings.
>
> Regards,
> Martin
>
> --
> http://mail.python.org/mailman/listinfo/python-list
__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com
More information about the Python-list
mailing list