From: Brian M. <mrb...@gm...> - 2006-02-02 16:36:41
|
You are successfully loading the unicode u'a\u2019s' into the variable, s, with no problem other than displaying in a old-fashioned shell. The best I am able to do in my Emacs Python shell is >>> s.encode('cp1252') 'a\x92s' >>> print s.encode('cp1252') a\222s So, I don't get any error with CP-1252. I think if you want the quote mark to appear as a quote mark, you will have to work in a more modern GUI window, such as the Code Editor Shell. This article "Unicode in Python" by Jason Orendorff helped me understand a similar DOS window Python unicode problem. http://www.jorendorff.com/articles/unicode/python.html Search the article for the word "unfortunately" and read from that point. He concludes with " So in general it is not possible to determine what encoding to use with print. It is therefore better to send Unicode output to files or Unicode-aware GUIs, not to sys.stdout." I have not found anything to contradict this conclusion. I found that from the links collected in another good article, "Unicode Secrets" by Uche Ogbuji May 18, 2005 http://www.xml.com/pub/a/2005/05/18/unicode.html Good luck |