redho home | products | services

Programming Forums


Community for Java, PHP, Perl C, ASP and Python programmers

Ask your IT question here

troubles with unicode


Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Programming Forums -> Python programming forum
View previous topic :: View next topic  
Author Message
Jackil
Enthusiastic Coder


Joined: 24 May 2006
Posts: 97
Hi guys. I got some problems with parsing a xml file while running a script on both linux and windows. Should I save the file as utf-8 on both platforms?

Reply with quote
 
BigDaddy
Enthusiastic Coder


Joined: 26 May 2006
Posts: 147
Jackil, what is the encoding of the xml file? what is giving you the option of saving as another encoding
And yes utf-8 should be OK as long as you read it back in as utf-8, and the xml parser accepts that

Reply with quote
 
Jackil
Enthusiastic Coder


Joined: 24 May 2006
Posts: 97
BigDaddy, hmm.. the encoding is specified as utf-8, but the file is fetched from a webserver though.
Reply with quote
 
BigDaddy
Enthusiastic Coder


Joined: 26 May 2006
Posts: 147
How are you fetching it?
Reply with quote
 
Jackil
Enthusiastic Coder


Joined: 24 May 2006
Posts: 97
I use urllib.urlopen
Reply with quote
 
BigDaddy
Enthusiastic Coder


Joined: 26 May 2006
Posts: 147
The result is a string, right?
Reply with quote
 
Jackil
Enthusiastic Coder


Joined: 24 May 2006
Posts: 97
Well, a filehandle
Which I then have created a small xml parser for

Reply with quote
 
BigDaddy
Enthusiastic Coder


Joined: 26 May 2006
Posts: 147
When reading it in, you might want to get it into unicode with stringjustread.decode('utf-8')
Reply with quote
 
Jackil
Enthusiastic Coder


Joined: 24 May 2006
Posts: 97
Hmm.. interesting.
Reply with quote
 
BigDaddy
Enthusiastic Coder


Joined: 26 May 2006
Posts: 147
To answer the original question, whatever worked on windows should work on linux, except that the system default encoding for 8-bit strings might be "windows-1252" and not "ascii"
Reply with quote
 
Page 1 of 3 Goto page 1, 2, 3  Next
Post new topic   Reply to topic    Programming Forums -> Python programming forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group