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
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,
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
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
> 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
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
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
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?
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
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
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
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
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
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
14 matches
Mail list logo