perl-unicode

Re: How to convert base64 string to utf-8

2004-02-02 12:30:05
ALexander N. Treyner wrote:
Hello All,
I'm using utf-8 Postgres database, where I save strings in many languages.
I have to match the database with strings encoded in mime base64 or quoted-printable format. Like next:
=?utf-8?B?15TXoNeUINee16nXlNeZINeR16LXkdeo15nXqi4=?=
or
=?KOI8-R?Q?=F0=D2=C9=D7=C5=D4=2C_=ED=C9=D2!!!?=

I think that I need first convert these strings to utf-8, but I can not find out how to do it.

You are looking for MIME::Words::decode_mimewords(). The function will also give you the charset of the decoded data, and if you are lucky enough, that charset will be known to Encode and you can convert it to UTF-8. Unfortunately, you will be out of luck for the somewhat common case of UTF-7 (unless it is available in Encode by now).

Ciao

Guido
--
Imperia AG, Development
Leyboldstr. 10 - D-50354 Hürth - http://www.imperia.net/