[Python-bugs-list] [ python-Bugs-404539 ] os.listdir() can't grok Unicode filename
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 06 Sep 2001 18:02:38 -0700
Bugs item #404539, was opened at 2001-02-27 01:15
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=404539&group_id=5470
Category: Unicode
Group: Feature Request
>Status: Pending
>Resolution: Works For Me
Priority: 5
Submitted By: Itamar Shtull-Trauring (itamar)
Assigned to: Mark Hammond (mhammond)
Summary: os.listdir() can't grok Unicode filename
Initial Comment:
I have a file whose name is part Hebrew, part English
on my W2K VMware install. Filenames on Win2000 are
Unicode, if I'm not mistaken. I'm running BeOpen Python
2.0, with the latest Pythonwin installed.
My problem - the os.listdir() command doesn't return
the name of the file in unicode, it just replaces the
hebrew characters with question marks - '?':
>>> l = os.listdir("c:\")
>>> l[-1]
'????.txt'
>>> type(l[-1])
<type 'string'>
Perhaps the os.listdir() function could be extended
with a unicode keyword, which would tell it to return
the filenames as unicode strings?
filenames = os.listdir(path, unicode=1)
----------------------------------------------------------------------
>Comment By: Mark Hammond (mhammond)
Date: 2001-09-06 18:02
Message:
Logged In: YES
user_id=14198
Works for me. Specifically,
see "Lib/test/test_unicode_file.py". This test
specifically creates a Unicode file (with extended
characters), and performs all sorts of tests - including
that it appears in os.listdir().
If you still feel this is a bug, please:
a) Check that test succeeds on your platform and with your
locale settings.
b) If it does work, try and change the test so it fails.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-02-28 11:29
Message:
Logged In: YES
user_id=31435
Assigned to MarkH in case he has a clue. The core Python
code doesn't know about any of MS's TCHAR-related tricks
(it uses plain 8-bit C strings everywhere).
----------------------------------------------------------------------
Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-02-28 11:13
Message:
Logged In: YES
user_id=3066
Tim, are you familiar with the directory searching functions under Windows? Can you determine the right thing to do?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=404539&group_id=5470