View Single Post
  #3 (permalink)  
Old 08-10-2003
sylvain sylvain is offline
Registered User
 
Name: Sylvain Fasel
Organization: university of Geneva
Project: quantum cryptographic systems
 
Join Date: Feb 2003
Location: Geneva (Switzerland)
Posts: 42
Quote:
Originally posted by marc
Can you try the following C++ code:

std::string s = "élephant";
std::cout << s << endl;

What does it print?
it prints:
élephant

Quote:
As a general note, I recommend to use unicode and std::wstring, and then convert to std::string:

std::wstring ws = ... "élephant" in unicode format ...
std::string s = IceUtil::wstringToString(ws); // s now holds "élephant" in utf-8
I tried the following modification of my previous code example:
(...)
std::string ss="élephant";
std::wstring ws(ss.begin(),ss.end());// in unicode format ...
Map.insert(std::make_pair("yes","elephant"));
Map.insert(std::make_pair("non",IceUtil::wstringTo String(ws)));
(...)
But the output is still wrong. By the way:
std::string ss="élephant";
std::wstring ws(ss.begin(),ss.end());// in unicode format ...
std::string s = IceUtil::wstringToString(ws); // s now holds "élephant" in utf-8
std::cout << s << std::endl;

prints:
élephant
as well...

Quote:
I don't think that this is the cause of your problems. But the on-the-wire string representation for the Ice protocol is UTF-8, not ISO-8859-15. If you don't use UTF-8, you won't be able to interoperate for example with Ice for Java if you use non-ASCII strings.
I think I will have to learn a little bit about wchar_t, UTF-8, and all that stuff. That was on my "to learn" list anyway...

Thank you.
Reply With Quote