Page 1 of 1
UTF-8 in e-mail subject - quoted printable?
Posted: Tue Feb 26, 2008 3:30 pm
by Kukulkan
Hi,
I use UTF-8 encoded templates to design messages for sending using gnozals PureSMTP. The used subject is encoded in this template, too. I set
Content-Type: text/html; charset=utf-8;
and the complete body is ok. Using Outlook and Thunderbird, the UTF-8 encoded subject is correct, too. But some e-mail programs (tobit david for example) fail to display the UTF-8 encoded subject of the e-mail.
How do I need to convert the subject for all kind of e-mail clients? Is there a quoted printable encoding algorithm available for PureBasic?
Kukulkan
Posted: Wed Feb 27, 2008 2:09 am
by pdwyer
My understanding is that the subject of an email must be in 7bit ascii to be standard. For subjects that contain other codings (like UTF8 etc) they have a type marker and then the bytes encoded in base64.
like this
Subject: =?utf-8?B?UkEU6IEVNUyAtIFRFU1Q5IOCuOOCueOBmOOFg+OBquOBj+OBpg==?=
=?utf-8?B?
Posted: Wed Feb 27, 2008 9:19 am
by Kukulkan
Hi pdwyer,
Thank you. Your information completed the puzzle.
I found the following way to manage the problem using PB:
Code: Select all
Subject.s = "UTF-8 encoded string like Versandbestätigung"
SubjectBase64.s = Space(Len(Subject.s) * 2)
Base64Encoder(@Subject.s, Len(Subject.s), @SubjectBase64.s, Len(SubjectBase64.s))
Subject.s = "=?UTF-8?B?" + SubjectBase64.s + "?="
Seems to work without any problems...
Kukulkan
Posted: Wed Feb 27, 2008 10:06 am
by srod
Useful. Thanks.
Posted: Wed Feb 27, 2008 10:16 am
by pdwyer
Cheers, I was wondering if that would work...
Now I don't need to spend the time! Thanks
Posted: Tue Dec 30, 2008 9:59 pm
by Seymour Clufley
Is there a quoted printable encoding algorithm available for PureBasic?
Now I need such a function!
I found
this VB function but it involves using something called "CDO.Message object".
Can anyone help out?
Posted: Wed Dec 31, 2008 11:33 am
by Kukulkan
Hi,
Quoted Printable seem to be less complicated than UTF-8. The result may be such a string:
Original: Hätten Hüte ein ß im Namen, wären sie möglicherweise keine Hüte mehr, sondern Hüße.
QP: H=E4tten H=FCte ein =DF im Namen, w=E4ren sie m=F6glicherweise keine H=FCte= mehr, sondern H=FC=DFe.
Every byte that is not between 33–60 and 62–126 will be replaced by = followed by the uppercase hex value.
Here is more information:
http://en.wikipedia.org/wiki/Quoted-printable
Will be only a work of some minutes.
Kukulkan