Help needed: Printing unicode characters in user defined format

"Martin v. Löwis" martin at v.loewis.de
Thu Oct 21 20:57:19 CEST 2004


Pekka Niiranen wrote:
> I need to loop thru characters in Unicode string
> and store each character in format \U+hhhh, where
> hhhh is the value of unicode character in hexadecimal?

"".join(['\\U+%.4x' % ord(c) for c in unistr])

HTH,
Martin



More information about the Python-list mailing list