Archived Forum Post

Index of archived forum posts

Question:

Charset using LoadEML-Function

Sep 12 '14 at 14:20

Hey everyone, I wanted to ask you if someone can explain how the CkEmail does handle the charset for the function LoadEML().

I need to load my created eml-file from the path "f:\tester öffentlich.eml "

The Output Shows an ANSI error! So it does Interpret the word "öffentlich" as "ffentlich" and Fails to load it.

Is there a way to load an EML even with this special german chars? Without the special char/ vowel in the filename it works. Just want to make sure it is not a bug and maybe I am doing something wrong on my end?

Tried this:

email.put_Charset("utf-8");

and

email.put_Utf8(true);

Output for lastErrorText as follows:

ChilkatLog:

LoadEml:

DllDate: Jul 31 2014

ChilkatVersion: 9.5.0.43

Architecture: Little Endian; 32-bit

Language: Visual C++ 9.0 (32-bit)

VerboseLogging: 0

loadEml2:

  emlPath: f:\tester öffentlich.eml

  loadFileX:

    Failed to open file (2)

    localFilePath: f:\tester ffentlich.eml

    currentWorkingDirectory: C:\Users\Release

    osErrorInfo: Das System kann die angegebene Datei nicht finden.

    localWindowsFilePath: f:\tester ffentlich.eml

    Failed to open for read.

  --loadFileX

--loadEml2

Failed.

--LoadEml

--ChilkatLog


Answer

If you hard-coded the filename as a literal string within your C++ source code, it was probably saved in the ANSI charset. Therefore, when the string is passed to LoadEml, you are passing ANSI chars. You would not want to set the "Utf8" property equal to true. The Utf8 property tells the Chilkat object instance how it should interpret any "const char " parameters passed by the app -- as either ANSI or utf-8. (it also controls the charset of any "const char " lowercase alternative method/property return values)

The email object's Charset property controls the charset to be used when rendering the email to MIME, such as when sending email or saving to .eml. It is not related to the interpretation of "const char *" method args.


Answer

Thank you. I might have my solution by doing it this way (changing put_Utf8() from case to case in the very same function):

//create file with german and other Special chars (eg.: ä,ü,ö)
CkEmail email;
email.put_Utf8(true);//for spec chars in values inside mail

//fill object for mail
email.put_Subject(mycstringhere);// has Special chars maybe german, russian or hebrew in it!
/...

//save that eml to a filename with special chars for german language
email.put_Utf8(false);
success = email.SaveEML(pathgerman)//pathgerman is a CString that holds Special chars as "c:\test\öffentlich\öäüß.eml" for the path

Answer

I don't think you are clearly understanding the meaning and purpose of the "Utf8" property (i.e. get_Utf8(), put_Utf8())

A "const char *" in C/C++ is a sequence of bytes terminated by a null byte. The Utf8 property tells Chilkat how to interpret the bytes -- as characters represented in the utf-8 encoding, or as characters represented in the ANSI encoding. The Utf8 property is only concerned with the passing of "const char *" arguments and making sure the bytes are interpreted correctly. Therefore, the "Utf8" property is common to all Chilkat C++ classes.