Tkinter wart: returned texts are sometimes strings, sometime Unicode strings
Eric Brunel
eric.brunel at pragmadev.com
Thu Mar 20 13:11:35 EST 2003
Hi all,
I stepped again on a problem I had too many times, and I must ask: why on earth
do Tkinter return plain strings when getting a text value using only ASCII
charcaters and a Unicode string when the same text contains anything else? This
forces to do things like:
if type(text) == type(unicode('')): text = text.encode(...)
everywhere, which is:
1/ utterly ugly
2/ really too easy to forget
Why not return plain strings encoded as UTF-8, for example? That way, everything
should always work and one should never get UnicodeError's again, or even
stranger errors (like line endings printing as string '\n' instead of real line
endings...). I really don't see the point in returning once an object with one
type, and once with another type _depending on the user's input_... Returning a
string encoded as UTF-8 makes much more sense to me... If the user wants another
encoding, the text may be reencoded via unicode(...).encode(...) afterwards.
Any opinions?
--
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
More information about the Python-list
mailing list