How to print first(national) char from unicode string encoded in utf-8?
Marco Bizzarri
marco.bizzarri at gmail.com
Mon Sep 1 09:39:47 EDT 2008
On Mon, Sep 1, 2008 at 3:25 PM, <sniipe at gmail.com> wrote:
>
> When I do ${urllib.unquote(c.user.firstName)} without encoding to
> latin-1 I got different chars than I will get: no Łukasz but Å ukasz
> --
> http://mail.python.org/mailman/listinfo/python-list
That's crazy. "string".encode('latin1') gives you a latin1 encoded
string; latin1 is a single byte encoding, therefore taking the first
byte should be no problem.
Have you tried:
urlib.unquote(c.user.firstName)[0].encode('latin1') or
urlib.unquote(c.user.firstName)[0].encode('utf8')
I'm assuming here that the urlib.unquote(c.user.firstName) returns an
encodable string (which I'm absolutely not sure), but if it does, this
should take the first 'character'.
Regards
Marco
--
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
More information about the Python-list
mailing list