Re: converting to and from octal escaped UTF--8

2007-12-04 Thread MonkeeSage
On Dec 3, 8:10 am, Michael Goerz <[EMAIL PROTECTED]> wrote: > MonkeeSage wrote: > > On Dec 3, 1:31 am, MonkeeSage <[EMAIL PROTECTED]> wrote: > >> On Dec 2, 11:46 pm, Michael Spencer <[EMAIL PROTECTED]> wrote: > > >>> Michael Goerz wrote: > Hi, > I am writing unicode stings into a special

Re: converting to and from octal escaped UTF--8

2007-12-04 Thread Piet van Oostrum
> Michael Goerz <[EMAIL PROTECTED]> (MG) wrote: >MG> if (ord(character) < 32) or (ord(character) > 128): If you encode chars < 32 it seems more appropriate to also encode 127. Moreover your code is quadratic in the size of the string so if you use long strings it would be better to u

Re: converting to and from octal escaped UTF--8

2007-12-03 Thread Michael Goerz
MonkeeSage wrote: > On Dec 3, 1:31 am, MonkeeSage <[EMAIL PROTECTED]> wrote: >> On Dec 2, 11:46 pm, Michael Spencer <[EMAIL PROTECTED]> wrote: >> >> >> >>> Michael Goerz wrote: Hi, I am writing unicode stings into a special text file that requires to have non-ascii characters as as o

Re: converting to and from octal escaped UTF--8

2007-12-02 Thread MonkeeSage
On Dec 3, 1:31 am, MonkeeSage <[EMAIL PROTECTED]> wrote: > On Dec 2, 11:46 pm, Michael Spencer <[EMAIL PROTECTED]> wrote: > > > > > Michael Goerz wrote: > > > Hi, > > > > I am writing unicode stings into a special text file that requires to > > > have non-ascii characters as as octal-escaped UTF-8

Re: converting to and from octal escaped UTF--8

2007-12-02 Thread MonkeeSage
On Dec 2, 11:46 pm, Michael Spencer <[EMAIL PROTECTED]> wrote: > Michael Goerz wrote: > > Hi, > > > I am writing unicode stings into a special text file that requires to > > have non-ascii characters as as octal-escaped UTF-8 codes. > > > For example, the letter "Í" (latin capital I with acute, cod

Re: converting to and from octal escaped UTF--8

2007-12-02 Thread Michael Spencer
Michael Goerz wrote: > Hi, > > I am writing unicode stings into a special text file that requires to > have non-ascii characters as as octal-escaped UTF-8 codes. > > For example, the letter "Í" (latin capital I with acute, code point 205) > would come out as "\303\215". > > I will also have to r

Re: converting to and from octal escaped UTF--8

2007-12-02 Thread Michael Goerz
MonkeeSage wrote: > Looks like escape() can be a bit simpler... > > def escape(s): > result = [] > for char in s: > result.append("\%o" % ord(char)) > return ''.join(result) > > Regards, > Jordan Very neat! Thanks a lot... Michael -- http://mail.python.org/mailman/listinfo/python-list

Re: converting to and from octal escaped UTF--8

2007-12-02 Thread MonkeeSage
On Dec 2, 8:38 pm, Michael Goerz <[EMAIL PROTECTED]> wrote: > Michael Goerz wrote: > > Hi, > > > I am writing unicode stings into a special text file that requires to > > have non-ascii characters as as octal-escaped UTF-8 codes. > > > For example, the letter "Í" (latin capital I with acute, code p

Re: converting to and from octal escaped UTF--8

2007-12-02 Thread Michael Goerz
Michael Goerz wrote: > Hi, > > I am writing unicode stings into a special text file that requires to > have non-ascii characters as as octal-escaped UTF-8 codes. > > For example, the letter "Í" (latin capital I with acute, code point 205) > would come out as "\303\215". > > I will also have to r