🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #43

TIdMessage SaveToFile stores with signs letter ???????

#43
From: akhramovichsa
Date: Tue, 27 Jan 2009 16:33
85 lines
4322 bytes
There is an application e-mail client to send and receive letters,
written in BDS2008.
Using the mail through Indy10.
With the formation of a new writing component, through TIdMessage,
first letter is saved in a file for later shipment.

     TIdMessage * IdMessageSave = new TIdMessage (NULL);

     IdMessageSave-> Clear ();
     IdMessageSave-> MessageParts-> Clear ();

     IdMessageSave-> CharSet = "koi8-r";
     IdMessageSave-> AttachmentEncoding = "MIME";
     IdMessageSave-> ContentType = "text / plain; charset = \" koi8-r
\ ";";
     IdMessageSave-> Encoding = meMIME;

     IdMessageSave-> From-> Address = WIN_TO_KOI (this-> From);
     IdMessageSave-> Recipients-> EMailAddresses = WIN_TO_KOI (this->
To);
     IdMessageSave-> Subject = WIN_TO_KOI (this-> Subject);
     IdMessageSave-> Body-> Text = WIN_TO_KOI (this-> Body);

     IdMessageSave-> SaveToFile (this-> Path);
     IdMessageSave-> ~ TIdMessage ();


When migrating to the CodeGear RAD Studio 2009 letter written to the
file, but instead of Cyrillic letters are displayed signs of "??????"
Here's an example of a saved message:

From: "aaaa@com.net" <aaaa@com.net>
Subject: ???????? ?????????
To: bbbb@com.net
Content-Type: text / plain; charset = "koi8-r";
MIME-Version: 1.0
Date: Sun, 25 Jan 2009 18:39:11 +0300

???? ??????????, ???????? ?????? ??????? ?????????? ? ????????? ??????, ?????????? ??
BDS2008.
?????? ? ?????? ?????????????? ????? Indy10.
??? ???????????? ?????? ?????? ????? ????????? ?
IdMessage, ?????? ??????? ??????????? ? ???? ??? ??????????? ????????


Tried to maintain through the flow, the result is the same, the flow
has become question marks
     TMemoryStream * buffer = new TMemoryStream ();
     IdMessageSave-> SaveToStream (buffer);

     TStringList * mail_raw_str = new TStringList ();
     buffer-> Position = 0;
     mail_raw_str-> LoadFromStream (buffer);
     mail_raw_str-> SaveToFile (this-> Path);


Search on the Internet suggested that the problem is hidden in Indy in
the method TIdMessage:: SaveToStream (...).
Actually the question, how to fix this bug?


PS: The function WIN_TO_KOI
UnicodeString WIN_TO_KOI (UnicodeString str)
(
     UnicodeString res_str;
     UnicodeString SKoi =
"ЈіеАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя;
     UnicodeString SWin =
"eETyuabtsdefghiyklmnopyarstuzhvyzsheschchYuABTsDEFGHIYKLMNOPYaRSTUZhVYZShESchCh;
     int k;
     for (int i = 1; i <= str.Length (); i + +)
     (
         int pos = AnsiPos (str [i], SWin);
         if (pos == 0) (res_str + = str [i];)
         else (res_str + = SKoi [pos];)
     )
     return res_str;
)
Technical Details
Message-ID: <12cdac45-0a1a-42e5-94ac-0934c783ae4d@s9g2000prg.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!s9g2000prg.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,4f5bfa22e6524f64,start
X-Google-Attributes: gid11508e,domainid0,public,usenet
X-Google-Language: ENGLISH,UTF8
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!s9g2000prg.googlegroups.com!not-for-mail
From: akhramovichsa@gmail.com
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: TIdMessage SaveToFile stores with signs letter ???????
Date: Tue, 27 Jan 2009 08:33:31 -0800 (PST)
Organization: http://groups.google.com
Lines: 85
Message-ID: <12cdac45-0a1a-42e5-94ac-0934c783ae4d@s9g2000prg.googlegroups.com>
NNTP-Posting-Host: 89.106.168.250
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1233074012 31154 127.0.0.1 (27 Jan 2009 16:33:32 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 27 Jan 2009 16:33:32 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: s9g2000prg.googlegroups.com; posting-host=89.106.168.250; 
 posting-account=JMXVAwoAAABhUn5wLN1vevhuWWPOAP-F
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) 
 AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.43 Safari/525.19,gzip(gfe),gzip(gfe)