How to print first(national) char from unicode string encoded in utf-8?
sniipe at gmail.com
sniipe at gmail.com
Mon Sep 1 08:57:37 EDT 2008
Hi,
I have a problem with unicode string in Pylons templates(Mako). I will
print first char from my string encoded in UTF-8 and urllib.quote(),
for example string 'Łukasz':
${urllib.unquote(c.user.firstName).encode('latin-1')[0:1]}
and I received this information:
<type 'exceptions.UnicodeDecodeError'>: 'utf8' codec can't decode byte
0xc5 in position 0: unexpected end of data
When I change from [0:1] to [0:2] everything is ok. I think it is
because of unicode and encoding utf-8(2 bytes).
How to resolve this problem?
Best regards
More information about the Python-list
mailing list