eEcho blog

is een halte van de gedachte

Python unicode

Probleem

International toepassing die input krijgt in codepage 1251, koi, of andere moet deze input converteren in UTF-8 en bewaren in database.

Oplossing

Gebruik standard python bibliotheek om conversie te uitvoeren in unicode

unicode(’hello’) (ascii)

of

unicode(’hello’, ‘iso-8859-1′)

a.encode(’utf8′, ‘replace’)

of

a.encode(’utf8′, ‘ignore’)

Links

http://www.iana.org/assignments/character-sets
http://www.python.org/dev/peps/pep-0100/

Add A Comment

You must be logged in to post a comment.

Home | info@eecho.info | Voorwaarden | Blog