Re: Python strings outside the 128 range

2006-07-17 Thread Michael Piotrowski
On 2006-07-17 Piet van Oostrum <[EMAIL PROTECTED]> wrote: That might be a good heuristic - but on my Mac no LANG is set. So I should paraphrase my statement to "There is no reliable and cross-platform way figuring out which encoding the console uses". > >>> If LANG is not set, it's

Re: Python strings outside the 128 range

2006-07-17 Thread Piet van Oostrum
> Michael Piotrowski <[EMAIL PROTECTED]> (MP) wrote: >MP> On 2006-07-14 "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >>> Sybren Stuvel schrieb: Diez B. Roggisch enlightened us with: > Of course not. AFAIK there is no way figuring out which encoding the > target console supports.

Re: Python strings outside the 128 range

2006-07-17 Thread Michael Piotrowski
On 2006-07-14 "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Sybren Stuvel schrieb: >> Diez B. Roggisch enlightened us with: >>> Of course not. AFAIK there is no way figuring out which encoding the >>> target console supports. The best you can do is to offer an option >>> that allwos selection of

Re: Python strings outside the 128 range

2006-07-14 Thread Gerhard Fiedler
On 2006-07-14 12:07:12, Fredrik Lundh wrote: > umm. what are we talking about here, really ? Aha! You took a big load off my chest -- this is pretty much what I thought should be there :) What I was talking about is that Diez responded with a clear "no" to my question whether print would do the

Re: Python strings outside the 128 range

2006-07-14 Thread Fredrik Lundh
Gerhard Fiedler wrote: > Anyway, it seems that anything non-ASCII is a bit problematic and needs > "manual" handling of the runtime environment encoding. Seems a bit odd, > given the worldwide distribution of Python... I would have thought that > such a rather basic task like printing an accented

Re: Python strings outside the 128 range

2006-07-14 Thread Gerhard Fiedler
On 2006-07-14 10:52:22, Diez B. Roggisch wrote: Will print take care of encoding translation according to the encoding used in the target console? >>> >>> Of course not. AFAIK there is no way figuring out which encoding the >>> target console supports. The best you can do is to offer an

Re: Python strings outside the 128 range

2006-07-14 Thread Diez B. Roggisch
Sybren Stuvel schrieb: > Diez B. Roggisch enlightened us with: >> Of course not. AFAIK there is no way figuring out which encoding the >> target console supports. The best you can do is to offer an option >> that allwos selection of the output encoding. > > You can use the LANG environment variabl

Re: Python strings outside the 128 range

2006-07-14 Thread Diez B. Roggisch
Gerhard Fiedler schrieb: > On 2006-07-13 12:04:58, Richard Brodie wrote: > >>> s = "é" >>> print s > >>> Is there a standard way to do this? >> Use Unicode strings, with an explicit encoding. Say no to ISO-8859-1 >> centrism. >> See: http://www.amk.ca/python/howto/unicode particularly the >>

Re: Python strings outside the 128 range

2006-07-13 Thread Gerhard Fiedler
On 2006-07-13 12:04:58, Richard Brodie wrote: >> s = "é" >> print s >> Is there a standard way to do this? > > Use Unicode strings, with an explicit encoding. Say no to ISO-8859-1 > centrism. > See: http://www.amk.ca/python/howto/unicode particularly the > "Unicode Literals in Python Source

Re: Python strings outside the 128 range

2006-07-13 Thread Richard Brodie
"Gerhard Fiedler" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If I understand you correctly, you are saying that if I distribute a file > with the following lines: > > s = "é" > print s > > I basically need to distribute also the information how the file is encoded > and ever

Re: Python strings outside the 128 range

2006-07-13 Thread Fredrik Lundh
Gerhard Fiedler wrote: > If I understand you correctly, you are saying that if I distribute a file > with the following lines: > > s = "é" > print s > > I basically need to distribute also the information how the file is encoded > and every user needs to use the same (or a compatible) encoding

Re: Python strings outside the 128 range

2006-07-13 Thread Gerhard Fiedler
On 2006-07-13 07:42:51, Fredrik Lundh wrote: >> Could anyone explain me how the python string "é" is mapped to >> the binary code "\xe9" in my python interpreter ? > > in the iso-8859-1 character set, the character é is represented by the code > 0xE9 (233 in decimal). there's no mapping going on

Re: Python strings outside the 128 range

2006-07-13 Thread Piet van Oostrum
> "Sébastien Boisgérault" <[EMAIL PROTECTED]> (SB) wrote: >SB> Hi, >SB> Could anyone explain me how the python string "é" is mapped to >SB> the binary code "\xe9" in my python interpreter ? That is not done in the python interpreter. It is done in the editor in which you prepare your python

Re: Python strings outside the 128 range

2006-07-13 Thread Sébastien Boisgérault
Fredrik Lundh wrote: > in the iso-8859-1 character set, the character é is represented by the code > 0xE9 (233 in decimal). there's no mapping going on here; there's only one > character in the string. how it appears on your screen depends on how you > print it, and what encoding your terminal

Re: Python strings outside the 128 range

2006-07-13 Thread Fredrik Lundh
Sébastien Boisgérault wrote: > Could anyone explain me how the python string "é" is mapped to > the binary code "\xe9" in my python interpreter ? in the iso-8859-1 character set, the character é is represented by the code 0xE9 (233 in decimal). there's no mapping going on here; there's only one

Re: Python strings outside the 128 range

2006-07-13 Thread Diez B. Roggisch
Sébastien Boisgérault schrieb: > Hi, > > Could anyone explain me how the python string "é" is mapped to > the binary code "\xe9" in my python interpreter ? > > "é" is not present in the 7-bit ASCII table that is the default > encoding, right ? So is the mapping "é" -> "\xe9" portable ? > (site-)c

Python strings outside the 128 range

2006-07-13 Thread Sébastien Boisgérault
Hi, Could anyone explain me how the python string "é" is mapped to the binary code "\xe9" in my python interpreter ? "é" is not present in the 7-bit ASCII table that is the default encoding, right ? So is the mapping "é" -> "\xe9" portable ? (site-)configuration dependent ? Can anyone have somet