Dear LC Gurus,

I am working with LC 7.0-dp6, and need to parse some raw email messages, 
translating headers that were encoded using base64 or quoted-printable encoding 
back to ‘normal’ text. The email headers in these messages look like these 
samples:

> ============
> Subject: 
> =?UTF-8?B?e1N1YSBtZWxob3Igb3DDp8OjbyF8QSBtZWxob3Igb3DDp8OjbyBlbSBTYcO6ZGUgIXxBIG1lbGhvciBvcMOnw6NvIGVtIFNhw7pkZSBlc3TDoSBhcXVpICF9?=
> From: "=?UTF-8?B?UXVhbGljb3JwIFNhw7pkZQ==?=" <[email protected]>

And:

> ============
> From: =?utf-8?Q?=E2=98=85?= Brittni Seger =?utf-8?Q?=E2=98=85?= 
> <[email protected]>
> To: [email protected]
> Subject: =?UTF-8?B?SGV5IHN3ZWV0eSwgZG8geW91IHdhbnQgdG8gSEFWRSBTT01FIEZVTj8=?=
> ============

Headers containing non-ascii characters should always be encoded in either 
base64 or ‘quoted-printable’ format. The header format then becomes:

* =?charEncoding?B?encodedString?= (for base64)
* =?charEncoding?Q?encodedString?= (for quoted-printable)

So, in the first example above, the ‘from’ header contains UTF-8 characters, 
encoded in base64 encoding.
In the second example, the ‘from’ header contains UTF-8 characters encoded as 
‘quoted-printable’.

Using matchText() it’s easy to extract the encoded string, but I’m having a 
couple of issues:

1) How to decode from “quoted-printable” to normal text?  Is there a ready-made 
function somewhere?

2) LiveCode’s base64decode() function seems to assume that we are always 
dealing with ascii text - this is using version 7.0-dp6. If I get the 
base64decode of "UXVhbGljb3JwIFNhw7pkZQ==“ (the sender of the first example 
above), I get "Qualicorp Sa√∫de”, when I should be getting “Qualicorp Saúde”. 

I guess that somehow I should be telling LiveCode that these characters are 
UTF-8, but in LiveCode 7.0 isn’t everything supposed to be unicode by default? 
The functions that we would have used in previous versions (uniEncode, 
uniDecode) are now deprecated, so in a situation like this, what should be used?

Any guidance would be much appreciated.

Kindest regards,

--
Igor Couto
Sydney, Australia

_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to