Re: [Tutor] symbol encoding and processing problem

2007-10-19 Thread Tim Golden
Timmie wrote: > I am totally lost: > * python has ascii as default encoding > * my linux uses UTF-8 (therefore all files created on linux are UTF-8) > * windows uses cp1250 > * IPtyhon something else: on the machine where I am currently on stdin is set > to > cp850 > > So what encoding to I use t

Re: [Tutor] symbol encoding and processing problem

2007-10-19 Thread Timmie
> > I still don't know why there is such a encoding mess on Python. For me > this > > totally neglects the statement that python code is easily portable or > executable > > on other platforms. > > I don't think this is entirely fair. For example at the start you had a > file containing cp1252 dat

Re: [Tutor] symbol encoding and processing problem

2007-10-18 Thread Kent Johnson
Timmie wrote: >> Was the problem with the print statements? Maybe changing the console >> encoding would help. I have some notes here: >> http://personalpages.tds.net/~kent37/stories/00018.html > Thanks, I read it yesterday evening. > > I still don't know why there is such a encoding mess on Pyth

Re: [Tutor] symbol encoding and processing problem

2007-10-18 Thread Timmie
> Was the problem with the print statements? Maybe changing the console > encoding would help. I have some notes here: > http://personalpages.tds.net/~kent37/stories/00018.html Thanks, I read it yesterday evening. I still don't know why there is such a encoding mess on Python. For me this totally

Re: [Tutor] symbol encoding and processing problem

2007-10-18 Thread Timmie
> Just be aware that this affects portability of your scripts; they will > require this same change to run on other systems. For this reason you > might want to change the code instead. > If you give a specific example of what is failing I will try to help. >From the previous posts I learned tha

Re: [Tutor] symbol encoding and processing problem

2007-10-17 Thread Kent Johnson
Evert Rol wrote: >>> >>> print unicode("125° 15' 5.55''", 'utf-8') >>> UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in >>> position 3: ordinal not in range(128) >> >> This is the same as the first encode error. > > This is the thing I don't get; or only partly: I'm sending a

Re: [Tutor] symbol encoding and processing problem

2007-10-17 Thread Evert Rol
raw = unicode("125° 15' 5.55''", 'utf-8') >>> Again, I think this can be simplified to >>>raw = u"125° 15' 5.55''" >> It does, but it's getting confusing when I compare the following: >> >>> raw = u"125° 15' 5.55''" >> 125° 15' 5.55'' > > Where does that output come from? sorry, my bad:

Re: [Tutor] symbol encoding and processing problem

2007-10-17 Thread Kent Johnson
Evert Rol wrote: >>> raw = unicode("125° 15' 5.55''", 'utf-8') >> Again, I think this can be simplified to >>raw = u"125° 15' 5.55''" > > It does, but it's getting confusing when I compare the following: > > >>> raw = u"125° 15' 5.55''" > 125° 15' 5.55'' Where does that output come from? >

Re: [Tutor] symbol encoding and processing problem

2007-10-17 Thread Evert Rol
>> raw = unicode("125° 15' 5.55''", 'utf-8') > > Again, I think this can be simplified to >raw = u"125° 15' 5.55''" It does, but it's getting confusing when I compare the following: >>> raw = u"125° 15' 5.55''" 125° 15' 5.55'' >>> print u"125° 15' 5.55''" UnicodeEncodeError: 'ascii' codec

Re: [Tutor] symbol encoding and processing problem

2007-10-17 Thread Kent Johnson
Timmie wrote: > OK, I found out. >> Since it didn't work in IPython as well I assume that I need to change the >> encoding of the IPython shell to UTF-8, too. Still need to find out where. > Put a file called 'sitecustomize.py' into any directory on your PYTHONPATH. > > write the folowing two line

Re: [Tutor] symbol encoding and processing problem

2007-10-17 Thread Timmie
OK, I found out. > Since it didn't work in IPython as well I assume that I need to change the > encoding of the IPython shell to UTF-8, too. Still need to find out where. Put a file called 'sitecustomize.py' into any directory on your PYTHONPATH. write the folowing two lines in that file: import

Re: [Tutor] symbol encoding and processing problem

2007-10-17 Thread Kent Johnson
Timmie wrote: >> Get an editor on Windows that can edit UTF-8 text files and file >> transfer software that doesn't change the text encoding. Work with UTF-8 >> exclusively. > Thanks. This sounds really trivial but the thing is that one cannot define > file > encoding in PythonWin. Really! Tha

Re: [Tutor] symbol encoding and processing problem

2007-10-17 Thread Tim Golden
Timmie wrote: >>> from easygui import easygui >>> raw = unicode("121ø 55' 5.55''", 'utf-8') >>> => gets a encoding error >> Then your source file is not really in UTF-8. > This really helped! > > >> Get an editor on Windows that can edit UTF-8 text files and file >> transfer software that doesn

Re: [Tutor] symbol encoding and processing problem

2007-10-17 Thread Timmie
> > from easygui import easygui > > raw = unicode("121ø 55' 5.55''", 'utf-8') > > => gets a encoding error > > Then your source file is not really in UTF-8. This really helped! > Get an editor on Windows that can edit UTF-8 text files and file > transfer software that doesn't change the text e

Re: [Tutor] symbol encoding and processing problem

2007-10-17 Thread Kent Johnson
Timmie wrote: > I tried your advice yesterday evening. > >> And see if you get a ç. > I see this character. > > from easygui import easygui > raw = unicode("121ø 55' 5.55''", 'utf-8') > => gets a encoding error Then your source file is not really in UTF-8. BTW you can simply say raw = u"121ø

Re: [Tutor] symbol encoding and processing problem

2007-10-17 Thread Timmie
I tried your advice yesterday evening. > And see if you get a ç. I see this character. from easygui import easygui raw = unicode("121ø 55' 5.55''", 'utf-8') => gets a encoding error raw = unicode("121ø 55' 5.55''", 'cp1250') => this works while coding on windows. How do I make it work really cro

Re: [Tutor] symbol encoding and processing problem

2007-10-16 Thread Tim Michelsen
> How do you get this output? The print is after the statement causing the > traceback. Are you showing the same code as you ran? Yes. I created this file in PythonWin and run it with IPython. > It displays correctly for me (on MacOS X). Are you sure your source is > actually encoded in utf-8? N

Re: [Tutor] symbol encoding and processing problem

2007-10-16 Thread Kent Johnson
Tim Michelsen wrote: > Dear list, > I have encountered a problem with encoding of user input and variables. > Heres my test script: Posting without the line numbers would make it easier to try your code. > > 1 #!/usr/bin/env python > 2 # -*- coding: utf-8 -*- > 3 from easygui import easygui >

Re: [Tutor] symbol encoding and processing problem

2007-10-16 Thread Evert Rol
Hi Tim, > 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

[Tutor] symbol encoding and processing problem

2007-10-16 Thread Tim Michelsen
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)