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