[Python-Dev] fun with unicode, part 1

M.-A. Lemburg mal@lemburg.com
Thu, 27 Apr 2000 12:27:18 +0200


Fredrik Lundh wrote:
> 
> >>> filename = u"gröt"
> 
> >>> file = open(filename, "w")
> >>> file.close()
> 
> >>> import glob
> >>> print glob.glob("gr*")
> ['gr\303\266t']
> 
> >>> print glob.glob(u"gr*")
> [u'gr\366t']
> 
> >>> import os
> >>> os.system("dir gr*")
> ...
> GRÇôT                    0  01-02-03  12.34 grÇôt
>          1 fil(es)              0 byte
>          0 dir         12 345 678 byte free
> 
> hmm.

Where is the problem ? If you pass the output of glob()
to open() you'll get the same file in both cases...
even better, you can now even use Chinese in your filenames
without the OS having to support Unicode filenames :-)

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/