This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: locale.getdefaultlocale() returns wrong encoding
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ajung, jlgijsbers, quiver
Priority: normal Keywords:

Created on 2004-11-08 07:11 by ajung, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg23063 - (view) Author: Andreas Jung (ajung) Date: 2004-11-08 07:11
ajung@localhost:~/sandboxes/Zope/Zope: locale
LANG=
LC_CTYPE=fr_FR.UTF8
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
ajung@localhost:~/sandboxes/Zope/Zope: python2.3
Python 2.3.4 (#1, Nov  6 2004, 11:45:40)
[GCC 3.4.2] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import locale
>>> locale.getpreferredencoding()
'UTF-8'
>>> locale.getdefaultlocale()
['fr_FR', 'utf']
>>>

As you can see the encoding is set to 'UTF-8' but
getdefaultlocale()
returns only 'utf'. If I set LC_CTYPE e.g. to
'fr_FR.iso-8859-10 then the
right encoding is returned.

Affected: Python 2.3.4, 2.4b1
OS: Linux i386 Fedora Core 2
msg23064 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-11-08 10:57
Logged In: YES 
user_id=469548

In Python, 'utf' is an alias for 'utf-8'. With that
knowledge, is this still a problem?
msg23065 - (view) Author: Andreas Jung (ajung) Date: 2004-11-08 11:03
Logged In: YES 
user_id=11084

hmmm...what about utf16, utf32?

-aj
msg23066 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-11-08 11:16
Logged In: YES 
user_id=469548

Well, I don't know how to test them (are there any utf16 or
utf32 locales), but I assume that those would return
'utf16'/'utf32' or one of their aliases.
msg23067 - (view) Author: George Yoshida (quiver) (Python committer) Date: 2004-11-08 12:20
Logged In: YES 
user_id=671362

All listings of standard encodings are here:
  http://docs.python.org/lib/node127.html (Py 2.3)
  http://www.python.org/dev/doc/devel/lib/standard-
encodings.html (Py 2.4)

> what about utf16, utf32?
U16 and utf16 is an alias for utf-16, but it looks like utf-32 is 
not supported yet.

Back to the original post, as Johannes said earlier, utf is an 
alias for utf-8, so locale.getdefaultlocale() returns *right* 
encoding.


msg23068 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-11-08 16:22
Logged In: YES 
user_id=469548

utf32 is supported: try doing 'import codecs;
codecs.lookup('utf32'). Closing this as there doesn't seem
to be a bug here.
History
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41149
2004-11-08 07:11:55ajungcreate