EldoS | Feel safer!

Software components for data protection, secure storage and transfer

TElPlainTextPart - how to get body text in correct character set?

Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.
Posted: 03/12/2015 04:56:21
by Jesse Klaasse (Basic support level)
Joined: 03/12/2015
Posts: 1

I am using SecureBlackBox to retrieve messages from a POP3 server (which is gmail in this case, but that is not important).

There seems to go something wrong with the character encoding.

At some point in the (C#) code, I use:
int errorLevel;
if (messagePart is TElPlainTextPart)
    var messagePlainTextPart = messagePart as TElPlainTextPart;

    var txt = string.Empty;
    errorLevel = messagePlainTextPart.GetText(ref txt); // TODO this doesn't seem to handle special characters properly

    File.WriteAllText(localFile, txt);
    errorLevel = messagePart.SaveDataToFile(localFile);

The body contents should be: "één ja" (without quotes), so with two 'special' characters in it. However, the txt string contains: "????n ja\r\n" (without quotes).

While debugging, when I inspect the messagePlainTextPart object, I can see that the CharSet is "UTF-8", the BodyLen is 18, and the Data array contains 20 bytes. I can't really explain the actual contents of the Data array, it seems to me that it's UTF-16, since each byte is followed by a 0-byte:

When I try to decode the Data array myself, the results are not as expected:

"????n ja\r\n"
"?\0?\0?\0?\0n\0 \0j\0a\0\r\0\n\0"

How should I get the correct contents??

Posted: 03/12/2015 05:01:58
by Alexander Ionov (EldoS Corp.)

Moved to Helpdesk for investigation

Best regards,
Alexander Ionov



Topic viewed 454 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!