Re: Printing Filenames with non-Ascii-Characters

2005-02-08 Thread "Martin v. Löwis"
Marian Aldenhövel wrote: > If you're printing to the console, modern Pythons will try to guess the > console's encoding (e.g. cp850). But it seems to have quessed wrong. I don't blame it, I would not know of any way to reliably figure out this setting. It's actually very easy. Python invokes GetC

Re: Printing Filenames with non-Ascii-Characters

2005-02-08 Thread "Martin v. Löwis"
Marian Aldenhövel wrote: dir = os.listdir(somepath) for d in dir: print d The program fails for filenames that contain non-ascii characters. 'ascii' codec can't encode characters in position 33-34: I cannot reproduce this. On my system, all such file names print just fine,

Re: Printing Filenames with non-Ascii-Characters

2005-02-03 Thread vincent wehren
Marian Aldenhövel wrote: Hi, > Python's drive towards uncompromising explicitness pays off big time when you're dealing with multilingual data. Except for the very implicit choice of 'ascii' as an encoding when it cannot make a good guess of course :-). Since 'ascii' is a legal subset Unicode and

Re: Printing Filenames with non-Ascii-Characters

2005-02-03 Thread Marian Aldenhövel
Hi, > Python's drive towards uncompromising explicitness pays off big time when you're dealing with multilingual data. Except for the very implicit choice of 'ascii' as an encoding when it cannot make a good guess of course :-). All in all I agree, however. Ciao, MM -- Marian Aldenhövel, Rosenhain

Re: Printing Filenames with non-Ascii-Characters

2005-02-02 Thread aurora
> print d.encode('cp437') So I would have to specify the encoding on every call to print? I am sure to forget and I don't like the program dying, in my case garbled output would be much more acceptable. Marian I'm with you. You never known you have put enough encode in all the right places a

Re: Printing Filenames with non-Ascii-Characters

2005-02-02 Thread vincent wehren
Marian Aldenhövel wrote: But wouldn't that be correct in my case? This is what I get inside Eclipse using pydev when I run: import os dirname = "c:/test" print dirname for fname in os.listdir(dirname): print fname if os.path.isfile(fname): print fname : c:/test straßenschild.png te

Re: Printing Filenames with non-Ascii-Characters

2005-02-02 Thread Marian Aldenhövel
Hi, Have you set the coding cookie in your file? Yes. I set it to Utf-8 as that's what I use for all my development. Try adding this as the first or second line. # -*- coding: cp850 -*- Python will then know how your file is encoded That is relevant to the encoding of source-files, right? How does

Re: Printing Filenames with non-Ascii-Characters

2005-02-02 Thread Max M
Marian Aldenhövel wrote: > If you're printing to the console, modern Pythons will try to guess the > console's encoding (e.g. cp850). But it seems to have quessed wrong. I don't blame it, I would not know of any way to reliably figure out this setting. Have you set the coding cookie in your file?

Re: Printing Filenames with non-Ascii-Characters

2005-02-02 Thread Marian Aldenhövel
Hi, Don't be tempted to ever change sys.defaultencoding in site.py, this is site specific, meaning that if you ever distribute them, programs relying on this setting may fail on other people's Python installations. But wouldn't that be correct in my case? > If you're printing to the console, mode

Re: Printing Filenames with non-Ascii-Characters

2005-02-02 Thread Marian Aldenhövel
Hi, Thank you very much, you have collectively cleared up some of the confusion. English windows command prompt uses cp437 charset. To be exact my Windows is german but I am not outputting to the command prompt window. I am using eclipse with the pydev plugin as development platform and the output

Re: Printing Filenames with non-Ascii-Characters

2005-02-01 Thread vincent wehren
Marian Aldenhövel wrote: Hi, I am very new to Python and have run into the following problem. If I do something like dir = os.listdir(somepath) for d in dir: print d The program fails for filenames that contain non-ascii characters. 'ascii' codec can't encode characters in

Re: Printing Filenames with non-Ascii-Characters

2005-02-01 Thread Serge Orlov
Marian Aldenhövel wrote: > Hi, > > I am very new to Python and have run into the following problem. If I do > something like > >dir = os.listdir(somepath) >for d in dir: > print d > > The program fails for filenames that contain non-ascii characters. > >'ascii' codec can't encode

Re: Printing Filenames with non-Ascii-Characters

2005-02-01 Thread aurora
On Tue, 01 Feb 2005 20:28:11 +0100, Marian Aldenhövel <[EMAIL PROTECTED]> wrote: Hi, I am very new to Python and have run into the following problem. If I do something like dir = os.listdir(somepath) for d in dir: print d The program fails for filenames that contain

Printing Filenames with non-Ascii-Characters

2005-02-01 Thread Marian Aldenhövel
Hi, I am very new to Python and have run into the following problem. If I do something like dir = os.listdir(somepath) for d in dir: print d The program fails for filenames that contain non-ascii characters. 'ascii' codec can't encode characters in position 33-34: I have