Starting point for unicode conversion

  • Thread starter Howard Lightstone
  • Start date
H

Howard Lightstone

I *foolishly* started a Python project (3 years ago) with considering
Unicode issues. Now, I want to resolve future problems with international
versions of my software.

The key point here is Tkinter. I believe (from reading this list) that I
can expect that SOME returned text may be Unicode (depending on content and
Windows locale settings).

Would it be best to just (somehow) force all text into Unicode or would it
be "better" to handle specific instances?

I also have the problem of embedded text in data files I create that I have
to store as *something* that I can fully recover and convert back to
something reasonable even if the locale changes.

Any thoughts welcome .... this is something I am NOT looking forward to.

Thanks
 
M

Martin v. =?iso-8859-15?q?L=F6wis?=

Howard Lightstone said:
The key point here is Tkinter. I believe (from reading this list) that I
can expect that SOME returned text may be Unicode (depending on content and
Windows locale settings).

Yes, and no. Yes, some returned text may be Unicode, but no, it won't
depend on the locale settings. Instead, Tkinter will return a byte
string if the result contains only ASCII characters, and return a
Unicode string if there are non-ASCII characters.
Would it be best to just (somehow) force all text into Unicode or would it
be "better" to handle specific instances?

If you are prepared to deal with Unicode, it would be best to force
that throughout. I was contemplating to make this an option in
_tkinter, but that has not been implemented - contributions are
welcome.

Meanwhile, you can use

s = unicode(s)

on all strings returned from Tkinter: if s is an ASCII string, the
default encoding should happily convert it to a Unicode object; if s
is a Unicode string, unicode(s) will be a no-op.
I also have the problem of embedded text in data files I create that I have
to store as *something* that I can fully recover and convert back to
something reasonable even if the locale changes.

Don't worry about the locale; it does not matter here.

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top