|
From: Bartosz O. <li...@bz...> - 2007-01-28 12:12:57
|
On 01/28/2007 06:26 AM, James Lockie wrote:
[...]
> I am trying to modify the AmarokGaim plugin so that it works with
> non-utf8 strings like "Bj=F6rk".
>
> It calls "message =3D message.decode('utf8')" where message might be th=
e
> string "Bj=F6rk".
[...]
The decode() method converts a string into a Unicode string (which is jus=
t
an internal representation and not the thing which you can pass anywhere
further). The argument specifies *current* encoding of the string. Thus i=
f
you know it's not utf-8 then you should not be giving utf-8 as the argume=
nt.
Unicode string is what you can later convert into other encodings, includ=
ing
utf-8.
In general, if you want to convert something into UTF-8, you should do:
message =3D message.decode(ENCODING_OF_MESSAGE).encode('utf-8')
The only problem is finding out what the proper value of ENCODING_OF_MESS=
AGE
is, but Sean has already mentioned how to do it.
take care,
Bartosz
|