Dear list, I have encountered a problem with encoding of user input and variables.
I want to read in user defined coordinates as a string like: 121° 55' 5.55'' Furthermore I would like to extract the degrees (integer number before the " ° " sign), the minutes (integer number before the " ' " sign) and the seconds (floating point number before the " '' " sign). When reading and processing the degree part I get some errors: Heres my test script: 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 from easygui import easygui 4 import sys 5 #raw = sys.argv[1] 6 raw = easygui.enterbox(message="Enter something.", title="", argDefaultText="20° 12' 33''") 7 #unicode = unicode(raw) 8 #conv = raw.encoding('latin-1') 9 split = raw.split('°') 10 out = raw 11 print out 12 easygui.msgbox(out) Here ist my output: 20° 12' 33'' Traceback (most recent call last): File "C:\python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "D:\python\scripts\encoding-test.py", line 22, in ? split = raw.split('°') UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 0: ordinal not in range(128) Traceback (most recent call last): File "C:\python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "D:\python\scripts\encoding-test.py", line 22, in ? split = raw.split('°') UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 0: ordinal not in range(128) Therefore my question: * How can I split at the "°" without getting a charater encoding error? * How do I have to encode the "°"-symbol that it gets correctly displayed in the Easygui msgbox at line 6? Thanks inadvance for answering, Timmie _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor