length of unicode strings

Michael Hudson mwh at python.net
Fri Aug 23 12:03:02 EDT 2002


teg at redhat.com (Trond Eivind Glomsrød) writes:

> The entire system is running a utf-8 locale... the problem is that
> python doesn't treat is as such, and I don't see a way to make it do
> so.

How can python tell that what's coming down stdin is in fact utf-8?
Is there some handy environment variable to check?

> What I'll probably need is a way for python to set all these strings
> as unicode by default...

Well, there's python -U, but I'd be amazed if that is what you want.

[...]
> Yes. It boils down to a need to get python to recognize the string as
> unicode automatically and mark it as such.

A literal that goes [double quote] stuff [double quote] has type str
today.  Is that want you want to change?  Brr.  Don't personally like
that idea.

OTOH, if what you want to do is have u"<utf-8>" work as expected, then
PEP 263 is your friend for source files; doubt there's a solution for
the interactive console.

Cheers,
M.

-- 
  Q: What are 1000 lawyers at the bottom of the ocean?
  A: A good start.
  (A lawyer told me this joke.)
                                  -- Michael Ströder, comp.lang.python



More information about the Python-list mailing list