# note that we use raw strings to avoid having to use double back
slashes below
utf8_repr() works same as repr() when processing ascii string
>>> utf8_repr('abc') == utf8_repr("abc") ==
repr('abc') == repr("abc") == "'abc'" True
>>> utf8_repr('a"b"c') == repr('a"b"c') ==
'\'a"b"c\'' True >>> utf8_repr("a'b'c") ==
repr("a'b'c") == '"a\'b\'c"' True >>>
utf8_repr('a\'b"c') == repr('a\'b"c') ==
utf8_repr("a'b\"c") == repr("a'b\"c") ==
'\'a\\\'b"c\'' True >>> utf8_repr('a\r\nb') ==
repr('a\r\nb') == "'a\\r\\nb'" # Test for \r, \n True
Unlike repr(), utf8_repr() remains utf8 content when processing utf8
string >>> utf8_repr('中文字') == utf8_repr("中文字") ==
"'中文字'" != repr('中文字') True >>>
utf8_repr('中"文"字') == "'中\"文\"字'" !=
repr('中"文"字') True >>> utf8_repr("中'文'字") ==
'"中\'文\'字"' != repr("中'文'字") True >>>
utf8_repr('中\'文"字') == utf8_repr("中'文\"字") ==
'\'中\\\'文"字\'' != repr('中\'文"字') ==
repr("中'文\"字") True >>> utf8_repr('中\r\n文') ==
"'中\\r\\n文'" != repr('中\r\n文') # Test for \r, \n True
|