[Sugar-devel] Unicode strings in translations

S. Daniel Francis francis at sugarlabs.org
Wed Aug 15 20:11:24 EDT 2012


2012/8/15 Manuel Kaufmann <humitos at gmail.com>:
> [humitos at michifus ~]$ python test.py
> UTF-8, set by the first line in the script
> len: 7
> last but one letter: �

We agree sometimes you could need the unicode for solve some conflicts
like this, but: How many translated strings are indexed by the
programs? I'm really sure there are too many activities where the
program doesn't iterate the string or any other possible conflicts.

> Changing the default encoding, as you said, is dangerous because we
> will be hiding the problem instead of resolving it. gtk people say
> this on the comments in the ticket that manuq reported.

We are stopping in very technical details, but you're not wrong in it.
Latin1 gives one bit for all the represented characters and the
supported characters aren't as many as with utf-8, it's for languages
with Latin derivation.

> So, the right way to handle and manipulate strings is using Unicode,
> with the "u" at the beginning of each string. That is the recommended
> way to do it. This is not me, I mean, it is not a whim. There are many
> reasons to use Unicode.

The right way only for handle and manipulate strings internally, and a
big part of the translated strings aren't handled or manipulated by
the activities, they are tasks for other libraries, preferentially
GTK, and it never generates a conflict for draw and format those
strings (including line wrapping), but for test it, you can make a
gtk.TextView in a python console and try to write only non-ascii
characters (for natural English speakers, you could generate many
´strange´ characters with the keyboard distribution "English
International").

> More information that you can read, pros and cons:
>
>  * http://www.shutupandship.com/2012/01/working-with-text-in-python-use-unicode.html
>  * http://stackoverflow.com/questions/1116449/should-i-use-unicode-string-by-default
>  * http://blog.ianbicking.org/illusive-setdefaultencoding.html
>  * http://nedbatchelder.com/blog/200401/printing_unicode_from_python.html
>  * http://getpython3.com/diveintopython3/strings.html#one-ring-to-rule-them-all
>  * http://blog.notdot.net/2010/07/Getting-unicode-right-in-Python

Thanks, there is many information here for read.

~danielf


More information about the Sugar-devel mailing list