Help needed: Printing unicode characters in user defined format

"Martin v. Löwis" martin at v.loewis.de
Thu Oct 21 14:57:19 EDT 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