[Python-bugs-list] [ python-Bugs-836035 ] strftime month name is encoded somehow

SourceForge.net noreply at sourceforge.net
Wed Nov 5 15:28:58 EST 2003


Bugs item #836035, was opened at 2003-11-04 21:49
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=836035&group_id=5470

Category: Unicode
>Group: Not a Bug
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Tim Evans (tim_evans)
Assigned to: M.-A. Lemburg (lemburg)
Summary: strftime month name is encoded somehow

Initial Comment:
On Windows XP, with some locales the month name
returned by time.strftime('%B') is encoded somehow. 
For example:

>>> import time, locale
>>> locale.setlocale(locale.LC_ALL, '')
"Chinese_People's Republic of China.936"
>>> time.strftime('%B')
'\xca\xae\xd2\xbb\xd4\xc2'
>>> time.strftime('%d %B %Y')
'05 \xca\xae\xd2\xbb\xd4\xc2 2003'

>>> locale.setlocale(locale.LC_ALL, '')
'French_France.1252'
>>> time.strftime('%B', (2003,12,1,0,0,0,0,0,0))
'd\xe9cembre'

I'm not sure what encoding the Chinese version is
using, but the French is compatible with latin-1.  It
would appear that the encoding used is locale-dependent.

Ideally, the win32 version of time.strftime would call
the wide-character version of strftime (called
wcsftime) and return a unicode object.

I haven't looked at what this does under any other
operating system.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2003-11-05 21:28

Message:
Logged In: YES 
user_id=21627

It always contains a byte string in the locale's encoding;
for compatibility, this cannot be changed.

On Windows, you can access the encoding as "mbcs". In
general, you need to use locale.getpreferredencoding() to
find out what encoding this string is in.

Closing as not-a-bug.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=836035&group_id=5470



More information about the Python-bugs-list mailing list