473,473 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SOS - unicode problems...

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
Jul 18 '05 #1
2 1271
On Tue, 23 Nov 2004 15:50:46 +0100, kepes.krisztian
<ke*************@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
Jul 18 '05 #2
Hello,
kepes.krisztian wrote:
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.
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: sebastien.hugues | last post by:
Hi I would like to retrieve the application data directory path of the logged user on windows XP. To achieve this goal i use the environment variable APPDATA. The logged user has this name:...
19
by: Gerson Kurz | last post by:
AAAAAAAARG I hate the way python handles unicode. Here is a nice problem for y'all to enjoy: say you have a variable thats unicode directory = u"c:\temp" Its unicode not because you want it...
8
by: Bill Eldridge | last post by:
I'm trying to grab a document off the Web and toss it into a MySQL database, but I keep running into the various encoding problems with Unicode (that aren't a problem for me with GB2312, BIG 5,...
30
by: aurora | last post by:
I have long find the Python default encoding of strict ASCII frustrating. For one thing I prefer to get garbage character than an exception. But the biggest issue is Unicode exception often pop up...
48
by: Zenobia | last post by:
Recently I was editing a document in GoLive 6. I like GoLive because it has some nice features such as: * rewrite source code * check syntax * global search & replace (through several files at...
2
by: Neil Schemenauer | last post by:
python-dev@python.org.] The PEP has been rewritten based on a suggestion by Guido to change str() rather than adding a new built-in function. Based on my testing, I believe the idea is...
2
by: bobnotbob | last post by:
I have created an application and am trying to call functions from a previously existing dll. I can call some functions fine, but I get a link error an when I try to call any function that takes...
19
by: Thomas W | last post by:
I'm getting really annoyed with python in regards to unicode/ascii-encoding problems. The string below is the encoding of the norwegian word "fødselsdag". I stored the string as "fødselsdag"...
9
by: Gerry | last post by:
I'm using pyExcelerator and xlrd to read and write data from and to two spreadsheets. I created the "read" spreadsheet by importing a text file - and I had no unicode aspirations. When I read...
1
by: Mudcat | last post by:
In short what I'm trying to do is read a document using an xml parser and then upload that data back into a database. I've got the code more or less completed using xml.etree.ElementTree for the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.