Reputation: 1019
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
Upvotes: 1
Views: 217
Reputation: 1019
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)
Upvotes: 1