TIdMessage.Body UTF-8 encoded

Giganews Newsgroups
Subject: TIdMessage.Body UTF-8 encoded
Posted by:  Boba (Bo…@somewhere.world)
Date: Fri, 14 Aug 2015

Dear All;  would someone please spare a minute and take
a look at the following code: when preparing TIdMessage
for transmission with TIdSMTP, what message params have
to be set to keep its body UTF-8 encoded?

{code:cpp}
//TIdMessage *IdMsg; - created by the IDE @ design time
  IdMsg->Clear();
  IdMsg->ContentType = "text/plain";
//IdMsg->ContentType = "text/plain; charset=UTF-8";
  IdMsg->CharSet = "UTF-8";
//IdMsg->ContentTransferEncoding = "quoted-printable";
  IdMsg->ContentTransferEncoding = "8bit";
  IdMsg->Body->Add( "US ASCII" );//looks OK
  IdMsg->Body->Add( "?£¥" );//non-ASCII characters ???
  TFileStream *fs = new TFileStream("msg.txt", fmCreate|fmShareExclusive);
  IdMsg->SaveToStream(fs);
  delete fs;
{/code}
the above code produces this "msg.txt" file:
{quote}
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
Date: Fri, 14 Aug 2015 06:49:22 -0500

US ASCII
??Y

..
{/quote}
as you can see "charset=UTF-8" is missing from the header
and non-ASCII chars are screwed.  Many thanks in advance.
PS: this is Indy10 distributed w/BCB12(aka 2009, CodeGear
    RAD Studio 6.0).

Replies