[SOLVED] QT5/gSOAP = encoding problem
-
Hi all!
I have problem encoding with gSOAP/QT5/Zend2/WSDL.
My russian string in bytes presented as: "H81:0" !!!
But gSOAP RECV.log shown that string is OK in server response!
What are missing? All source core in utf-8, wsdl and sever part in utf-8 too.
But MVS debugger shown that my sdt::string is "H81:0"! What are .... ?!
NOTE: All English charsets are OK.
NOTE2: setCodecForLocate does not give any effect. -
What does Qt have to do with your std::string coming out of gSOAP? How are you outputting the string?
Show us the input, expected output, and some code otherwise we could spend a long time guessing.
-
Hi Chris!
I just printout gSOAP *string *in QT program as:
fprintf(stdout, "string: %d\n", result.return_->string.c_srt());
OR
qDebug() << "String" << result.return_->string.c_srt();
OR
textInput.setTest(result.return_->string.c_srt());Where result.return_->string have type std::string.
And everywhere above I got "03>;>2>;" instead of "Заголовок".
I also tried result.return_->string.toLocal8Bit() and other but I get "03>;>2>;" again and again..
Please stop my nightmare, if it possible..
-
Try to ask on gSOAP support forum or on IRC channel... setCodecForLocate is for Qt strings only... In your case it has nothing to do with Qt.
-
Your example string "Заголовок" when UTF-8 encoded is a series of bytes with the following hex values:
D0 97 D0 B0 D0 B3 D0 BE D0 BB D0 BE D0 B2 D0 BE D0 BA
with two bytes per character in this case. You can check this by "dumping the std::string in hex":http://stackoverflow.com/questions/5990825/convert-an-ascii-stdstring-to-hex.If you printf() that to a console configured for the Windows 1251 (or other 8-bit encoding), which tries to treat each byte as a character, you will get garbled output.
To convert your std::string/C-string containing a UTF-8 encoded value into a QString you should try:
@
std::string s1;
QString value2 = QString::fromUtf8(s1.c_str());
// or
char *s2;
QString value2 = QString::fromUtf8(s2);
@ -
[quote author="AcerExtensa" date="1365145609"]Try to ask on gSOAP support forum or on IRC channel... setCodecForLocate is for Qt strings only... In your case it has nothing to do with Qt.[/quote]
Thank you!
'soap_init1(&soap_object, SOAP_C_UTFSTRING);' should be used for UTF-8 strings, without any affect of QT standart application.