Re: Trouble saving unicode text to file

2005-05-11 Thread Thomas Bellman
=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= <[EMAIL PROTECTED]> wrote: >Thomas Bellman wrote: >> Fixed-with characters *do* have advantages, even in the external >> representation. With fixed-with characters you don't have to >> parse the entire file or stream in order to read the Nth character; >

Re: Trouble saving unicode text to file

2005-05-10 Thread "Martin v. Löwis"
Thomas Bellman wrote: > Fixed-with characters *do* have advantages, even in the external > representation. With fixed-with characters you don't have to > parse the entire file or stream in order to read the Nth character; > instead you can skip or seek to an octet position that can be > calculated

Re: Trouble saving unicode text to file

2005-05-10 Thread Thomas Bellman
John Machin <[EMAIL PROTECTED]> wrote: > UTF-32 is yet another encoding. [...] > Once you have done codecs.open('inputfile', 'rb', 'utf_32') or > receivedstring.decode('utf_32'), what do you care whether your > *external representation* has fixed-width characters or not? > Putting it another way,

Re: Trouble saving unicode text to file

2005-05-10 Thread John Machin
On Tue, 10 May 2005 07:59:31 + (UTC), Thomas Bellman <[EMAIL PROTECTED]> wrote: >John Machin <[EMAIL PROTECTED]> writes: > >> Which raises a question: who or what is going to read your file? If a >> Unicode-aware application, and never a human, you might like to >> consider encoding the text a

Re: Trouble saving unicode text to file

2005-05-10 Thread Thomas Bellman
John Machin <[EMAIL PROTECTED]> writes: > Which raises a question: who or what is going to read your file? If a > Unicode-aware application, and never a human, you might like to > consider encoding the text as utf-16. Why would one want to use an encoding that is neither semi-compatible with ASCI

Re: Trouble saving unicode text to file

2005-05-09 Thread "Martin v. Löwis"
John Machin wrote: > Terminology disambiguation: what I call "users" wouldn't know what > 'cp1252' and 'iso-8859-1' were. They're not expected to know. They > just type in whatever characters they can see on their keyboard or > find in the charmap utility. It's what I'd call 'admins' and > 'develop

Re: Trouble saving unicode text to file

2005-05-09 Thread Fredrik Lundh
Max M wrote: >> (I just noticed that there's no euro sign on my swedish keyboard. I've >> never missed it ;-) > > It's probably "AltGR + E" like here in DK ah, there it is. almost entirely worn out. and it doesn't work. but a little fooling around reveals that AltGr+5 does work. oh well, you

Re: Trouble saving unicode text to file

2005-05-09 Thread Simon Brunning
On 5/9/05, Max M <[EMAIL PROTECTED]> wrote: > Fredrik Lundh wrote: > > > (I just noticed that there's no euro sign on my swedish keyboard. I've > > never missed it ;-) > > It's probably "AltGR + E" like here in DK My UK keyboard has it as AltGr + 4, FWIW. -- Cheers, Simon B, [EMAIL PROTECTED]

Re: Trouble saving unicode text to file

2005-05-09 Thread Max M
Fredrik Lundh wrote: > (I just noticed that there's no euro sign on my swedish keyboard. I've > never missed it ;-) It's probably "AltGR + E" like here in DK -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble saving unicode text to file

2005-05-09 Thread Fredrik Lundh
John Machin wrote: > I find it a bit hard to imagine that the euro sign wouldn't get a fair > bit of usage in Swedish data processing even if it's not their own > currency. it's spelled "Euro" or "EUR" in swedish. (if you live in a country that use letters to represent its own currency, you tend

Re: Trouble saving unicode text to file

2005-05-09 Thread F. Petitjean
Le Mon, 09 May 2005 08:39:40 +1000, John Machin a écrit : > On Sun, 08 May 2005 19:49:42 +0200, "Martin v. Löwis" ><[EMAIL PROTECTED]> wrote: > >>John Machin wrote: >>> Martin, I can't guess the reason for this last suggestion; why should >>> a Windows system use iso-8859-1 instead of cp1252? >> >

Re: Trouble saving unicode text to file

2005-05-08 Thread John Machin
On Sun, 08 May 2005 19:49:42 +0200, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: >John Machin wrote: >> Martin, I can't guess the reason for this last suggestion; why should >> a Windows system use iso-8859-1 instead of cp1252? > >Windows users often think that windows-1252 is the same thing as >i

Re: Trouble saving unicode text to file

2005-05-08 Thread "Martin v. Löwis"
John Machin wrote: > Martin, I can't guess the reason for this last suggestion; why should > a Windows system use iso-8859-1 instead of cp1252? Windows users often think that windows-1252 is the same thing as iso-8859-1, and then exchange data in windows-1252, but declare them as iso-8859-1 (in pa

Re: Trouble saving unicode text to file

2005-05-08 Thread John Machin
On Sun, 08 May 2005 11:23:49 +0200, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: >Svennglenn wrote: >> # -*- coding: cp1252 -*- >> >> titel = "åäö" >> titel = unicode(titel) > >Instead of this, just write > ># -*- coding: cp1252 -*- > >titel = u"åäö" > >> fil = open("testfil.txt", "w") >> fil.wri

Re: Trouble saving unicode text to file

2005-05-08 Thread "Martin v. Löwis"
Svennglenn wrote: > # -*- coding: cp1252 -*- > > titel = "åäö" > titel = unicode(titel) Instead of this, just write # -*- coding: cp1252 -*- titel = u"åäö" > fil = open("testfil.txt", "w") > fil.write(titel) > fil.close() Instead of this, write import codecs fil = codecs.open("testfil.txt",

Re: Trouble saving unicode text to file

2005-05-07 Thread Ivan Van Laningham
Hi All-- John Machin wrote: > > > The general rule in working with Unicode can be expressed something > like "work in Unicode all the time i.e. decode legacy text as early as > possible; encode into legacy text (if absolutely required) as late as > possible (corollary: if forced to communicate w

Re: Trouble saving unicode text to file

2005-05-07 Thread John Machin
On Sat, 7 May 2005 17:25:28 -0500, Skip Montanaro <[EMAIL PROTECTED]> wrote: > >Svennglenn> Traceback (most recent call last): >Svennglenn> File "D:\Documents and >Svennglenn> > Settings\Daniel\Desktop\Programmering\aaotest\aaotest2\aaotest2.pyw", >Svennglenn> line 5, in ? >

Re: Trouble saving unicode text to file

2005-05-07 Thread John Machin
On 7 May 2005 14:22:56 -0700, "Svennglenn" <[EMAIL PROTECTED]> wrote: >I'm working on a program that is supposed to save >different information to text files. > >Because the program is in swedish i have to use >unicode text for ÅÄÖ letters. "program is in Swedish": to the extent that this means "

Re: Trouble saving unicode text to file

2005-05-07 Thread Skip Montanaro
Svennglenn> Traceback (most recent call last): Svennglenn> File "D:\Documents and Svennglenn> Settings\Daniel\Desktop\Programmering\aaotest\aaotest2\aaotest2.pyw", Svennglenn> line 5, in ? Svennglenn> titel = unicode(titel) Svennglenn> UnicodeDecodeError: 'ascii' cod

Trouble saving unicode text to file

2005-05-07 Thread Svennglenn
I'm working on a program that is supposed to save different information to text files. Because the program is in swedish i have to use unicode text for ÅÄÖ letters. When I run the following testscript I get an error message. # -*- coding: cp1252 -*- titel = "åäö" titel = unicode(titel) print "