Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old September 9th, 2003, 08:57 AM
goudaman goudaman is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 26 goudaman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 33 m 34 sec
Reputation Power: 0
unicode, latin-1 and all that bore...

hi all!
Being a relatively newbie to python I ran into this problem:

I have an app with embedded python 2.2
Problem is that it has to run in german so it obviously needs to support ther german chars öäüÖÄÜß.
To test this i wrote this small script:

Code:
def umlaut(): 
     import locale      
     print "defaultlocale: " + str(locale.getdefaultlocale()) 
     umlautStr = "\xfc \xc4" 
     print "\\xfc encoded: " + umlautStr 

     a = "German special CHARs: äüö ÄÜÖ ß" 
     a = unicode(a,'latin-1') 
     try: 
          print "latin-1: " + str(a.encode('latin-1','replace')) 
     except: 
          print "encoding Latin not working" 
     try: 
          print "ascii:   " + (a.encode('ascii','replace')) 
     except: 
          print "encoding Ascii not working" 
     try: 
          print "cp1252:  " + str(a.encode('cp1252','replace')) 
     except: 
          print "encoding cp1252 not working" 
     return a 
 


to see the default encoding etc. (cause i just couldnt get it to work)
using the script in IDLE or the commandline it correctly gives:

Quote:
defaultlocale: ('de_DE', 'cp1252')
\xfc encoded: ü Ä
latin-1: German special CHARs: äüö ÄÜÖ ß
ascii: German special CHARs: ??? ??? ?
cp1252: German special CHARs: äüö ÄÜÖ ß
u'German special CHARs: \xe4\xfc\xf6 \xc4\xdc\xd6 \xdf'




with my implementation i get:

Quote:

defaultlocale: ('de_DE', 'cp1252')
\xfc encoded: ³ ─
latin-1: German special CHARs: ├ñ├╝├ ├ä├£├û ├ƒ
ascii: German special CHARs: ?????? ?????? ??
cp1252: German special CHARs: ├ñ├╝├ ├?├?├? ├?


I dont have the "encodings" folder in the app (i added it later by copying it in, but to little effect)

So my actual questions would be:
where do i start looking for the missing encodings? what .py .h .lib .whatever file am i missing here?
why doesnt it just work?
and who stole that marsbar from my desk drawer?

cheers

Chris

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > unicode, latin-1 and all that bore...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway