editing in Unicode

Bertilo Wennergren bertilow at hem.passagen.se
Fri Sep 8 17:21:21 EDT 2000


Martin von Loewis:

> "Bertilo Wennergren" <bertilow at hem.passagen.se> writes:

> > If I get this right the following simpler version ought to work:

> > msg=unicode("@#&")

> > Right? That I could live with.

> You can certainly do
>
> def _u(str):
>   return unicode(str,"utf-8")

> and then

> msg = _u("@#&")

Nice. Thanks.

> However, may I ask what unicode strings exactly you need in source
> code?  If you have messages to display, it may be that you want to
> support more than one language (BTW, which language are your messages
in?).

In my cgi work (hitherto done mostly in perl) Esperanto prevails.

> For multi-language applications, I recommend the use of the gettext
> module:

> from gettext import ugettext as _

> msg = _("hello")

> That will, at run-time, retrieve the translation of "hello" into
> Russian, German, whatever ... and return the translated string as a
> Unicode object. For that to work, you need the pygettext and msgfmt
> tools coming with Python 2.0.

Thanks for the suggestion. That could come in very handy.

Now I just have to start actually lerning some Python. It would be nice
to see a tutorial directed at those that already now perl...

--
#####################################################################
                         Bertilo Wennergren
                 <http://purl.oclc.org/net/bertilo>
                     <bertilow at hem.passagen.se>
#####################################################################





More information about the Python-list mailing list