SOS - unicode problems...


K

kepes.krisztian

Hi !

I use iso-8859-2 chrset (win1250), because I'm hungarian.

I create an audio tagger program in the past, but I found a problem in it.

I have the problem in the unicode string handling.

The error line is that:

nfn=track+\'/\'+alb+\'/\'+title+\'.mp3\'

It is concat the substrings for file rename.
Some of these string items are unicode, some of these not.
So I want to set unicode for all items before that line.
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 !

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


It is drop an error.
How to prevent this error, and convert (concat) the substrings to good
unicode string.

Please help me !
Thanx for it:
KK
 
Ad

Advertisements

M

Mitja

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
 
Ad

Advertisements

Y

Yury [remove empty]

Hello,
kepes.krisztian said:
Hi !

I use iso-8859-2 chrset (win1250), because I'm hungarian.
<skipped>
Try this:
s='Z\xf6rr'
q=s.decode('iso-8859-2')
Yo'll get unicode string

Yury.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top