How to convert unicode representation of non-ascii string to a python string as is? -
how can convert unicode-representation of non-ascii range string python string?
> str = '<some-arabic-content>' > decoded_str = str.decode('utf-8') > decoded_str u'\u0623\u0646\u0633\u0646\u0629' > str(decoded_str) <will-throw-an-error-ofc> since ascii cannot encode unicode string
how representation ('\u0623\u0646\u0633\u0646\u0629') python string? 1 below.
> str_rep = '\u0623\u0646\u0633\u0646\u0629'
i want land on str_rep
decoded_str
. how can go doing this?
decoded_str.encode("unicode-escape")
produces desired output.
Comments
Post a Comment