tkinter + unicode + bug or feature??
"Martin v. Löwis"
martin at v.loewis.de
Fri Jan 24 21:30:06 EST 2003
Bob van der Poel wrote:
> Okay. I'll have to look at the MegaWidget stuff later. I'm just thinking
> that doing something like string=entrywidget.get().encode('iso8859-1')
> should do the trick. Not sure, though, what encoding to use. Is there a
> pythonic way to determine the best to use?
Encoding the Unicode string should work, as would comparing it to other
Unicode strings - you should try to eliminate all non-ASCII byte strings
that represent text; then you can happily compare text strings.
There is really no way anybody could tell you what encoding to use: YOU
should know what encoding your text strings have - how could we possibly
know?
If you want to find out what encoding the user is likely to use, you
should use locale.nl_langinfo(locale.CODESET) on POSIX systems, and
locale.getlocale()[1] on Windows.
Regards,
Martin
More information about the Python-list
mailing list