Page 1 of 1

[solved] getText().c_str() unicode problem

Posted: Fri Sep 09, 2011 12:51
by Herpderp
Hello again.
I use the md5(string) function that returns a md5 hash of the string. I need to get the md5 hash of the CEGUI editbox. When there is english text in the txtPass edit window, everything is OK and my md5 function returns the same hash as the PHP md5() does. But when it comes to cyrillic characters, md5(str) returns incorrect hash (md5(cyrillicstring) == PHP md5(cyrillicstring) -- not my fault).
Here is the code:

Code: Select all

    std::string str(txtPass->getText().c_str());
    std::string str2="тест";
    std::cout << str << " = " << md5(str) << std::endl;
    std::cout << str2 << " = " << md5(str2) << std::endl;

The result:
Image
It seems that strings are same except the last symbol in str is <br> (str2 is correct hash).
Also I have no problem displaying cyrillic characters.
Thank you for your attention!

Re: getText().c_str() unicode problem

Posted: Fri Sep 09, 2011 22:31
by Herpderp
That strange!
I've discovered that there is (#10) symbol in the edit box. So I looked in my layout file and here it is!
<Property Name="Text" >тест
</Property>

For some odd reason, the default CEGUI layout editor placed the caret return symbol.

Re: getText().c_str() unicode problem

Posted: Sat Sep 10, 2011 12:33
by Kulik
Is the problem solved then?

Re: [solved] getText().c_str() unicode problem

Posted: Sat Sep 10, 2011 23:32
by Herpderp
Yeah, everything works fine now!