SOS - unicode problems...

Mitja nun at example.com
Tue Nov 23 10:20:36 EST 2004


On Tue, 23 Nov 2004 15:50:46 +0100, kepes.krisztian  
<kepes.krisztian at peto.hu> wrote:

> Hi !
>
> I use iso-8859-2 chrset (win1250), because I'm hungarian.
Those two are not the same thing, so first find out which one you're using.

> alb=unicode(alb)
> # alb=\'Zörr\' (album value is 'Zörr', where ö is o: (/xf6), a hung.  
> character).
> # it is came from a filename !
>
> But it is drop error !

Tell unicode which encoding to convert from, like this:
alb=unicode(alb,'iso-8859-2')
If you use win1250, use 'cp1250' as the second string.

>
> See this example that show the problem:
>
> s=\'Zörr\'
> s=u\'x\'+s+u\'y\'
> print s
>
> or
>
> s='Z\xf6rr'
> s=u'x'+s+u'y'
> print s

Convert s before joining it with x and y, or alternatively define it as an  
unicode string at the beginning:
   s=u'Z\xf6rr'
   s='x'+s+'y'
   print s

-- 
Mitja



More information about the Python-list mailing list