UTF-8 / German, Scandinavian letters - is it really this difficult?? Linux & Windows XP
Max M
maxm at mxm.dk
Tue Feb 22 08:50:12 EST 2005
Fuzzyman wrote:
> Mike Dee wrote:
>>#!/usr/bin/env python
>># -*- coding: UTF-8 -*-
> This will mean string literals in your source code will be encoded as
> UTF8 - if you handle them with normal string operations you might get
> funny results.
It means that you don't have to explicitely set the encoding on strings.
If your coding isn't set you must write:
ust = 'æøå'.decode('utf-8')
If it is set, you can just write:
ust = u'æøå'
And this string will automatically be utf-8 encoded:
st = 'æøå'
So you should be able to convert it to unicode without giving an encoding:
ust = unicode(st)
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
More information about the Python-list
mailing list