Title: RE: Unicode

Hi,

the problem was solved by using

print list[1].encode('iso8859_2')

I still wonder why this works, the book Python Essential Reference (Second Edition)
mentions to use

'iso-8859-1' for latin 1 (western europe)

and equivalently it should be

'iso-8859-2' for latin 1 (eastern europe)

Also the use of the encoding 'unicode-escape' was great help as it shows the actually unicode character number.

Thanks for the tip to use 'ignore' as second parameter, this was new to me.

Peter



> -----Original Message-----
> From: Martin Katz [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 11, 2002 7:16 PM
> To: Frey, Peter
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: Unicode
>
>
> Actually, you should use
>
>     print list[1].encode('latin1', 'ignore')
>
> This will eliminate the exception when a character has no latin1
> equivalent. This is simpler than the other alternatives.
>
> Martin Katz
>
> [EMAIL PROTECTED] wrote:
>
> > Hi,
> >
> > we had a similar problem with Outlook
> > try the following:
> >
> > print list[1].encode('latin1')
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, June 11, 2002 2:23 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Unicode
> > >
> > >
> > > Hi All,
> > >
> > > I am new in python.
> > > I found it very usefull, but :
> > > this string came from an ADO recordset and i cant do
> anything with it.
> > >
> > > >>> list[1]
> > > u'SCALA 5.1 Logisztika belf\xf6ld'
> > > >>> print list[1]
> > > Traceback (most recent call last):
> > >   File "<input>", line 1, in ?
> > > UnicodeError: ASCII encoding error: ordinal not in range(128)
> > >
> > > How can I use it with wxPython ?
> > > I can't print it, i can't use it to fill up a TreeCtrl ...
> > >
> > > Best regards,
> > > E-Mail: [EMAIL PROTECTED]
> > >
> > >
> > > _______________________________________________
> > > ActivePython mailing list
> > > [EMAIL PROTECTED]
> > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> > > Other options:
> > http://listserv.ActiveState.com/mailman/listinfo/ActivePython
> >
>
>

Reply via email to