Sending Emails with Indy (UTF-8)#

The other day I was a little dumbfounded. One of our systems is doing all string work using WideStrings and based on UTF-8, currently the probably best choice for international web sites. However, when sending Emails we depend on the Indy component library. Well, this worked pretty well until one customer decided to send e-mails in greek. Having been there this year, I realized the question marks all over the incoming e-mails where not what greek looks like ;-)

Upon investigating the source of the problem, I quickly realized that the Indy component library is still using the good old string type all over the place. Using UTF-8 and WideString everywhere I did never have to convert them to the standard Delphi string ever, but now I had too. I just did not know how to, there are quite a few functions that take a WideString and return an (Ansi)string. But which is right? Well, I asked Olaf Monien, one of the big supporters of the Indy component library to help me out.

The correct function to use is UTF8Encode. Thank you. Using TIdMessage, you have to set the CharSet property to 'UTF-8' as well. Due to a bug in plain text messages, you have to set the ContentType property to 'text/plain; CharSet=UTF-8' as well. I am sure, Olaf will check in some fix rather soon.

Sunday, October 28, 2007 3:14:23 PM (W. Europe Standard Time, UTC+01:00) #    Comments [0]  | 

 

Google AdSense


Comments are closed.
All content © 2010, Daniel Wischnewski
On this page
Archives
Promoted Links
Blogroll OPML
My current Flickr Images
www.flickr.com
Dies ist ein Flickr Modul mit �ffentlichen Fotos und Videos von dwischnewski. Ihr eigenes Modul k�nnen Sie hier erstellen.
Recommendations
Sitemap
Special Pages
Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Theme design by Jelle Druyts