String encoding

die_gestaltdie_gestalt Member Hanz FünzingerOrganization: self-employedProject: Various projects, trying to learn Ice
Hello,

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.

Comments

  • die_gestaltdie_gestalt Member Hanz FünzingerOrganization: self-employedProject: Various projects, trying to learn Ice
    Has somebody a piece of answer ?
    This is a very important issue for us.

    Thanks.
  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    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.
  • die_gestaltdie_gestalt Member Hanz FünzingerOrganization: self-employedProject: Various projects, trying to learn Ice
    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 !
Sign In or Register to comment.