Re: comparing Unicode and string
Neil Cerutti wrote:
Unless you're using unicode unfriendly editor or console, u"f\xfcr" is
the same as u"für":
True
So there is no need to write unicode strings in hexadecimal
representation of code points.
-- Leo
Neil Cerutti wrote:
On 2006-11-10, Steve Holden <steve@holdenwe b.comwrote:
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"
>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.
>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.
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"
the same as u"für":
>>u"f\xfcr" is u"für"
So there is no need to write unicode strings in hexadecimal
representation of code points.
-- Leo
Comment