Re: Unicode filenames

2019-12-07 Thread Chris Angelico
; many, many years! If they're that short and people are depending on them, it won't be too much work to port them. And you gain a huge measure of reliability: you no longer have to worry about "Unicode filenames" - or, to be more precise, "non-ASCII filenames" -

Re: Unicode filenames

2019-12-07 Thread Bob van der Poel
gt;>> that new file (it's a poor man's DB). > >>> > >>> Next, I can look up text in the file and open the saved filename. > >>> Everything works great until I hit those darn unicode filenames. > > ... > > >> Do you get the error with

Re: Unicode filenames

2019-12-07 Thread DL Neil via Python-list
ename and puts into an emacs buffer, and then lets me add information to that new file (it's a poor man's DB). Next, I can look up text in the file and open the saved filename. Everything works great until I hit those darn unicode filenames. ... Do you get the error with python 3? I

Re: Unicode filenames

2019-12-07 Thread Bob van der Poel
> > filename and puts into an emacs buffer, and then lets me add information > to > > that new file (it's a poor man's DB). > > > > Next, I can look up text in the file and open the saved filename. > > Everything works great until I hit those darn unicode

Re: Unicode filenames

2019-12-07 Thread Barry Scott
n to > that new file (it's a poor man's DB). > > Next, I can look up text in the file and open the saved filename. > Everything works great until I hit those darn unicode filenames. Yes the names you download are unicode. All OS can save that filename to disk these days. Can

Re: Unicode filenames

2019-12-07 Thread Peter Otten
an's DB). > > Next, I can look up text in the file and open the saved filename. > Everything works great until I hit those darn unicode filenames. > > Just to confuse me even more, the error seems to be coming from a bit of > tkinter code: > if sresults.has_key(textAt

Re: Unicode filenames

2019-12-06 Thread Terry Reedy
r man's DB). Next, I can look up text in the file and open the saved filename. Everything works great until I hit those darn unicode filenames. Just to confuse me even more, the error seems to be coming from a bit of tkinter code: if sresults.has_key(textAtCursor): bookname = os.

Re: Unicode filenames

2019-12-06 Thread DL Neil via Python-list
r man's DB). Next, I can look up text in the file and open the saved filename. Everything works great until I hit those darn unicode filenames. Just to confuse me even more, the error seems to be coming from a bit of tkinter code: if sresults.has_key(textAtCursor): bookname = os.

Unicode filenames

2019-12-06 Thread Bob van der Poel
e file and open the saved filename. Everything works great until I hit those darn unicode filenames. Just to confuse me even more, the error seems to be coming from a bit of tkinter code: if sresults.has_key(textAtCursor): bookname = os.path.expanduser(sresults[textAtCursor].strip())

Re: convert Unicode filenames to good-looking ASCII

2010-05-06 Thread coldpizza
Cool! Thanks to both Iliya and Peter! On May 6, 7:34 pm, Peter Otten <__pete...@web.de> wrote: > coldpizza wrote: > > Hello, > > > I need to convert accented unicode chars in some audio files to > > similarly-looking ascii chars. Looks like the following code seems to > > work on windows: > > > im

Re: convert Unicode filenames to good-looking ASCII

2010-05-06 Thread Peter Otten
coldpizza wrote: > Hello, > > I need to convert accented unicode chars in some audio files to > similarly-looking ascii chars. Looks like the following code seems to > work on windows: > > import os > import sys > import glob > > EXT = '*.*' > > lst_uni = glob.glob(unicode(EXT)) > > os.system

Re: convert Unicode filenames to good-looking ASCII

2010-05-06 Thread Iliya
Try smth like this: import unicodedata def remove_accents(str): nkfd_form = unicodedata.normalize('NFKD', unicode(str)) return u''.join([c for c in nkfd_form if not unicodedata.combining(c)]) -- http://mail.python.org/mailman/listinfo/python-list

convert Unicode filenames to good-looking ASCII

2010-05-06 Thread coldpizza
Hello, I need to convert accented unicode chars in some audio files to similarly-looking ascii chars. Looks like the following code seems to work on windows: import os import sys import glob EXT = '*.*' lst_uni = glob.glob(unicode(EXT)) os.system('chcp 437') lst_asci = glob.glob(EXT) print sys

Re: os.path.exists and unicode filenames

2006-11-07 Thread Martin v. Löwis
Peter Bienstman schrieb: > UnicodeEncodeError: 'ascii' codec can't encode characters in position 24-29: > ordinal not in range(128) > > I could try encoding the string in utg-8, but then it wouldn't work under > Windows. > > Is there an elegant cross-platform solution for this? I assume you ar

os.path.exists and unicode filenames

2006-11-07 Thread Peter Bienstman
Hi, I'm trying to add support for unicode file names to my application. I'm running into problems with e.g. the os.path.exists routine, which complains if it gets passed a unicode string: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mnemosyne/pyqt_ui/main_dlg.py",

Re: sax barfs on unicode filenames

2006-10-04 Thread Martin v. Löwis
the xml.sax layer, really (ET also uses Expat, and > doesn't seem to have any problems dealing with unicode filenames...) That's because ET never invokes XML_SetBase. Without testing, this suggests that there might be problem in ET with relative URIs in parsed external entities. XML_Se

Re: sax barfs on unicode filenames

2006-10-04 Thread Fredrik Lundh
oesn't seem to have any problems dealing with unicode filenames...) -- http://mail.python.org/mailman/listinfo/python-list

Re: sax barfs on unicode filenames: workaround

2006-10-04 Thread Martin v. Löwis
Edward K. Ream schrieb: > Happily, the workaround is easy. Replace theFile with: > > # Use cStringIo to avoid a crash in sax when inputFileName has unicode > characters. > s = theFile.read() > theFile = cStringIO.StringIO(s) > > My first attempt at a workaround was to use: > > s = theFile.read

Re: sax barfs on unicode filenames

2006-10-04 Thread Martin v. Löwis
Fredrik Lundh schrieb: > Diez B. Roggisch wrote: > >> Filenames are expected to be bytestrings. So what happens is that the >> unicode string you pass as filename gets implicitly converted using the >> default encoding. > > it is ? Yes. While you can pass Unicode strings as file names to many Py

Re: sax barfs on unicode filenames: workaround

2006-10-04 Thread Edward K. Ream
Happily, the workaround is easy. Replace theFile with: # Use cStringIo to avoid a crash in sax when inputFileName has unicode characters. s = theFile.read() theFile = cStringIO.StringIO(s) My first attempt at a workaround was to use: s = theFile.read() parser.parseString(s) but the expat pars

Re: sax barfs on unicode filenames

2006-10-04 Thread John Machin
Diez B. Roggisch wrote: > Edward K. Ream wrote: > > > Hi. Presumably this is a easy question, but anyone who understands the > > sax docs thinks completely differently than I do :-) > > > > > > > > Following the usual cookbook examples, my app parses an open file as > > follows:: > > > > > > > >

Re: sax barfs on unicode filenames

2006-10-04 Thread Edward K. Ream
> Filenames are expected to be bytestrings. The exception happens in a method to which no fileName is passed as an argument. parse_leo_file: 'C:\\prog\\tigris-cvs\\leo\\test\\unittest\\chinese?folder\\chinese?test.leo' (trace of converted fileName) Unexpected exception parsing C:\prog\tigris

Re: sax barfs on unicode filenames

2006-10-04 Thread Fredrik Lundh
Diez B. Roggisch wrote: > Filenames are expected to be bytestrings. So what happens is that the > unicode string you pass as filename gets implicitly converted using the > default encoding. it is ? >>> f = open(u"\u8116", "w") >>> f.write("hello") >>> f.close() >>> f = open(u"\u8116", "r") >>>

Re: sax barfs on unicode filenames

2006-10-04 Thread Diez B. Roggisch
Edward K. Ream wrote: > Hi. Presumably this is a easy question, but anyone who understands the > sax docs thinks completely differently than I do :-) > > > > Following the usual cookbook examples, my app parses an open file as > follows:: > > > > parser = xml.sax.make_parser() > > parser.s

sax barfs on unicode filenames

2006-10-04 Thread Edward K. Ream
Hi. Presumably this is a easy question, but anyone who understands the sax docs thinks completely differently than I do :-) Following the usual cookbook examples, my app parses an open file as follows:: parser = xml.sax.make_parser() parser.setFeature(xml.sax.handler.feature_external_ges,