简体   繁体   中英

Delphi version 2007 reading Cyrillic email with TIdMessage

We have built an email service that reads emails (from IMAP) and put them into a table in a database. And it works for German / English text, but now I want to get all other emails, like Cyrillic or Chinese too. But the characters that I receive are something like this: поново теŃтирам or even just ?????.

We are using ADO objects to store data in database and column type for those fields are declared as nvarchar, also parameters of a stored procedure that is used to upload that data are nvarchar too.

I presume that is the problem with Delphi 2007, but still I read on some posts here and there that Delphi 2007 supports Unicode (if Unicode I need). So, does anybody knows how to read email with Cyrillic and store it in mssql table?

To get text from IdMessage I am using IdMessage.Body.Text

Thanks, Dejan

And INDY version is 10.1.5

I have managed to make it working by using UTF8Decode function.

I have tested it with UTF-8 and ANSI charsets and it works in both cases (of course ANSI will produce ? in the places of Unicode characters).

declare BodyText and subject as WideStrings

after that just use:

BodyText := UTF8Decode(IdMessage.Body.GetText)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM