comparing Unicode and string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leo Kislov

    #16
    Re: comparing Unicode and string

    Neil Cerutti wrote:
    On 2006-11-10, Steve Holden <steve@holdenwe b.comwrote:
    >But I don't insist on my PEP. The example just shows just
    >another pitfall with Unicode and why I'll advise to any
    >beginner: Never write text constants that contain non-ascii
    >chars as simple strings, always make them Unicode strings by
    >prepending the "u".
    >
    That doesn't do any good if you aren't writing them in unicode
    code points, though.
    You tell the interpreter what encoding your source code is in.
    It then knows precisely how to decode your string literals into
    Unicode. How do you write things in "Unicode code points"?
    >
    for = u"f\xfcr"
    Unless you're using unicode unfriendly editor or console, u"f\xfcr" is
    the same as u"für":
    >>u"f\xfcr" is u"für"
    True

    So there is no need to write unicode strings in hexadecimal
    representation of code points.

    -- Leo

    Comment

    Working...