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
> 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
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
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
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
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
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
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
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