Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Converting HTML Unicode literals to characters with Python

Converting HTML Unicode literals to characters with Python
Thread Tools
Posting Junkie
Join Date: Jun 2001
Location: Washington DC
Status: Offline
Reply With Quote
Nov 1, 2007, 04:46 PM
 
So that's a somewhat confusing title, but basically this is what I want to know:

If I have the string '& # 31169 ;' (without the spaces, I had to add those so it would display the string rather than the character), which represents a Unicode character (in this case 私), how can I use python to recognize that as a single Unicode character rather than just the string of characters that makes up the Unicode representation? More to the point, if I had a whole string of such character representations (say a sentence in Japanese but represented in the ampersand pound format), how could I get Python to convert it to an actual Unicode string?
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Nov 1, 2007, 04:53 PM
 
Found this on the Python mailing list.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Posting Junkie
Join Date: Jun 2001
Location: Washington DC
Status: Offline
Reply With Quote
Nov 1, 2007, 05:18 PM
 
Sweet that did the trick. Thanks.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:34 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2