From: Alex T. <al...@tw...> - 2006-02-02 03:10:27
|
If I start up the Python interpreter (i.e. open a DOS shell box, and type "python") I get my Python interpreter. I then type in the following two lines, and get an error : > C:\Documents and Settings\Eleane>python > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] > on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> s = u'a\u2019s' > >>> print s > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "C:\Python24\lib\encodings\cp850.py", line 18, in encode > return codecs.charmap_encode(input,errors,encoding_map) > UnicodeEncodeError: 'charmap' codec can't encode character u'\u2019' > in position > 1: character maps to <undefined> > >>> If instead I start the PythonCard codeEditor, and start a Shell (F5), and type the same two lines, it works properly. I tried the basic python interpreter adding the imports that are visible within the codeEditor shell, but still get the same problem. > C:\Documents and Settings\Eleane>python > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] > on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import os > >>> import sys > >>> import wx > >>> from PythonCard import dialog, util > >>> s = u'a\u2019s' > >>> print s > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "C:\Python24\lib\encodings\cp850.py", line 18, in encode > return codecs.charmap_encode(input,errors,encoding_map) > UnicodeEncodeError: 'charmap' codec can't encode character u'\u2019' > in position > 1: character maps to <undefined> > >>> Anyone got any clues ? Does the code editor do something non-obvious that makes this all work right when it opens a shell ? Or is there something additional I could try ? [I don't really care about what the code editor does - just about being able to get my app working, perhaps by doing the same as the codeEditor.] (for now, I'm working around it by doing s = s.encode('ascii', 'replace') which simply replaces all the odd characters by '?'s - ok for the short term, but I do need to figure out a better answer). -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 267.14.25/247 - Release Date: 31/01/2006 |