Re: [Python-Dev] File encodings

2004-12-01 Thread M.-A. Lemburg
Gustavo Niemeyer wrote: [...] The idiom presented by Bob is the right way to go: wrap sys.stdout with a StreamWriter. I don't see that as a good solution, since every Python software that is internationalizaed will have do figure out this wrapping, introducing extra overhead unnecessarily. I don't

Re: [Python-Dev] File encodings

2004-11-30 Thread Walter Dörwald
Gustavo Niemeyer wrote: Hello Walter, I don't see that as a good solution, since every Python software that is internationalizaed will have do figure out this wrapping, introducing extra overhead unnecessarily. This wrapping is probably necessary for stateful encodings. If you had a sys.stdout.enco

Re: [Python-Dev] File encodings

2004-11-30 Thread Gustavo Niemeyer
Hello Walter, > >I don't see that as a good solution, since every Python software > >that is internationalizaed will have do figure out this wrapping, > >introducing extra overhead unnecessarily. > > This wrapping is probably necessary for stateful encodings. If you > had a sys.stdout.encoding=="

Re: [Python-Dev] File encodings

2004-11-30 Thread Walter Dörwald
Gustavo Niemeyer wrote: [...] You are mixing things here: The source encoding is meant for the parser and defines the way Unicode literals are converted into Unicode objects. The encoding used on the stdout stream doesn't have anything to do with the source code encoding and has to be handled diffe

Re: [Python-Dev] File encodings

2004-11-30 Thread Gustavo Niemeyer
[...] > You are mixing things here: > > The source encoding is meant for the > parser and defines the way Unicode literals are converted > into Unicode objects. > > The encoding used on the stdout stream doesn't have anything > to do with the source code encoding and has to be handled > different

Re: [Python-Dev] File encodings

2004-11-30 Thread Gustavo Niemeyer
> Gustavo Niemeyer wrote: > >Given the fact that files have an 'encoding' parameter, and that > >any unicode strings with characters not in the 0-127 range will > >raise an exception if being written to files, isn't it reasonable > >to respect the 'encoding' attribute whenever writing data to a > >

Re: [Python-Dev] File encodings

2004-11-30 Thread Gustavo Niemeyer
Hello Bob, [...] > >Given the fact that files have an 'encoding' parameter, and that > >any unicode strings with characters not in the 0-127 range will > >raise an exception if being written to files, isn't it reasonable > >to respect the 'encoding' attribute whenever writing data to a > >file? >

Re: [Python-Dev] File encodings

2004-11-30 Thread M.-A. Lemburg
Gustavo Niemeyer wrote: Greetings, Today, while trying to internationalize a program I'm working on, I found an interesting side-effect of how we're dealing with encoding of unicode strings while being written to files. Suppose the following example: # -*- encoding: iso-8859-1 -*- print u"á" Th

Re: [Python-Dev] File encodings

2004-11-30 Thread "Martin v. Löwis"
Gustavo Niemeyer wrote: Given the fact that files have an 'encoding' parameter, and that any unicode strings with characters not in the 0-127 range will raise an exception if being written to files, isn't it reasonable to respect the 'encoding' attribute whenever writing data to a file? In general,

Re: [Python-Dev] File encodings

2004-11-29 Thread Bob Ippolito
On Nov 29, 2004, at 2:04 PM, Gustavo Niemeyer wrote: Today, while trying to internationalize a program I'm working on, I found an interesting side-effect of how we're dealing with encoding of unicode strings while being written to files. Suppose the following example: # -*- encoding: iso-8859-1 -

[Python-Dev] File encodings

2004-11-29 Thread Gustavo Niemeyer
Greetings, Today, while trying to internationalize a program I'm working on, I found an interesting side-effect of how we're dealing with encoding of unicode strings while being written to files. Suppose the following example: # -*- encoding: iso-8859-1 -*- print u"á" This will correctly pr