This forum has been archived. Please start a new discussion on GitHub.

String encoding


I made a C++ server sending strings to a C# client.
The string contains characters like "é". Finally, the client receives an Unmarshall exception. Obviously, the source file is encoded in utf8.

I made a test with wstring :
std::wstring ws = L"é";
std::string myString = IceUtil::wstringToString(ws);

and now it works.

I'm using ice 3.3.0, and I read on previously threads that those kinds of bug have been corrected. So I don't understand why I can't directly use std::string, when my file is encoding in utf8.

Thanks for your help.


  • Has somebody a piece of answer ?
    This is a very important issue for us.

  • dwayne
    dwayne St. John's, Newfoundland
    It sounds like the string you are trying to send is not in UTF-8 format and therefore if you want to just use std::string you need to configure a string converter to convert it to UTF-8. See the manual for more information on string converters.

    I tried this out using the Ice/converter C++ demo and a C# server, using the string "Bonne journée". If I either just create the string in UTF-8 format ("Bonne journ\303\251e") or create it in non-UTF-8 ("Bonne journ\351e" which LATIN-1) and also configure a string converter then it works fine.

    However, if I just try to send the non-UTF-8 string without configuring a converter then the C# server throws a MarshalException because it receives a non-UTF-8 string.
  • Ok, I have to use WindowsStringConverter while I'm working on windows. I didn't think it was mandatory.

    Now it works.

    Thank you for your help Dwayne !