How to print first(national) char from unicode string encoded in utf-8?

Marco Bizzarri marco.bizzarri at
Mon Sep 1 15:39:47 CEST 2008

On Mon, Sep 1, 2008 at 3:25 PM,  <sniipe at> 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
> --

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


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'.

Marco Bizzarri

More information about the Python-list mailing list