Hello.
I'm having some problems with utf-8 and cxxtools.
In my application I'm using std::string to store the strings and
they're working fine and if I write to a file to the stdout, the text
is correctly written/printed. But when I try to serialize them (I'm
using it in a REST-like webservice), I have some problems with the
non-ascii chars.
For example, the code:
int main()
{
std::string name("Alçapão");
std::cout << name << std::endl;
std::cout << cxxtools::JsonSerializer::toString(name,"result") << std::endl;
cxxtools::Utf8Codec codec;
cxxtools::String wname(codec.decode(name));
std::cout << wname << std::endl;
std::cout << cxxtools::JsonSerializer::toString(wname,"result") << std::endl;
}
Prints:
Alçapão
{"result":"Al\u00c3\u00a7ap\u00c3\u00a3o"}
Alçapão
{"result":"Al\u00e7ap\u00e3o"}
What's a very strange result (at least for me).
So my question is: what can I do to serialize correctly std::string objects?
In another example, I encoded a std::string with the content
(serializating with jsonserializer and encoded as utf-8) "Avenida São
Paulo" and via the client (a web browser) it received: "Avenida São
Paulo", even I setting correctly the Content-Type.
Am I doing anything wrong (probably) or it may me a bug in cxxtools?
ps: as I already have the std::string objects in memory, I can't
recreate them from constants like in cxxtools::String(L"my unicode
string").
Thanks in advance.
--
-----
Sent from my Atari
------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general