Setting UTF-8 locale for python in Ubuntu 12.04 -
on ubuntu 12.04 vm (set using vagrant , hashicorp/precise64
box), locale says have utf-8
language, python getting latin-1
environment.
here's i'm seeing:
vagrant@vagrant:~$ locale lang=en_us.utf-8 language= 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=en_us vagrant@vagrant:~$ python python 2.7.3 (default, feb 27 2014, 19:58:35) [gcc 4.6.3] on linux2 type "help", "copyright", "credits" or "license" more information. >>> print u'\u1f41' traceback (most recent call last): file "<stdin>", line 1, in <module> unicodeencodeerror: 'latin-1' codec can't encode character u'\u1f41' in position 0: ordinal not in range(256)
how can true utf-8 system environment python?
the locale lc_ctype
ought en_us.utf-8
in locale
output. try
export lc_all="en_us.utf-8"
and if not work (as in lc_ctype
set explicitly), also:
export lc_ctype="en_us.utf-8"
Comments
Post a Comment