On Thu, 24 Feb 2005 07:51:04 -0500 Kent Johnson <[EMAIL PROTECTED]> wrote:
> Michael Lange wrote: > > I *thought* I would have to convert the user input which might be any > > encoding back into > > byte string first > > How are you getting the user input? Is it from the console or from a GUI? > It's a (Tkinter) gui, but anyway, I think I now understand why this idea is total nonsense. > If your intent is to create a unicode string, try this: > if not isinstance(result, unicode): > result = result.decode(sys.stdin.encoding) > Ok, user input must be checked whether it's unicode or not and if necessary be decoded to unicode with system encoding. For internal operations I should then use only unicode strings and if I need to print something to stdout I must encode it again with system encoding, right? > This article gives a lot of good background: > http://www.joelonsoftware.com/articles/Unicode.html > > I have written an essay about console encoding issues. At the end there is a > collection of links to > more general Python and Unicode articles. > http://www.pycs.net/users/0000323/stories/14.html > > Kent > That's great! Exactly the kind of articles I've been looking for but couldn't find. Thanks!!! Michael _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor