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

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Herpderp
Just popping in
Just popping in
Posts: 12
Joined: Wed Sep 07, 2011 22:43

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

Postby Herpderp » Fri Sep 09, 2011 12:51

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!
Last edited by Herpderp on Sat Sep 10, 2011 23:32, edited 2 times in total.

Herpderp
Just popping in
Just popping in
Posts: 12
Joined: Wed Sep 07, 2011 22:43

Re: getText().c_str() unicode problem

Postby Herpderp » Fri Sep 09, 2011 22:31

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.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: getText().c_str() unicode problem

Postby Kulik » Sat Sep 10, 2011 12:33

Is the problem solved then?

Herpderp
Just popping in
Just popping in
Posts: 12
Joined: Wed Sep 07, 2011 22:43

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

Postby Herpderp » Sat Sep 10, 2011 23:32

Yeah, everything works fine now!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 12 guests