Something about CEGUI::String

Discussion regarding the development of CEGUI itself - as opposed to questions about CEGUI usage that should be in the help forums.

Moderators: CEGUI MVP, CEGUI Team

lcy03406
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Fri Apr 24, 2009 01:18

Something about CEGUI::String

Postby lcy03406 » Sat Oct 10, 2009 01:53

Hi all.
I am developing games mainly on Windows with chinese language. That means, the wchar_t is 16 bits in UTF-16LE, and the Windows API expects char* to be in GBK, not in UTF-8. Since CEGUI is designed platform-independent, I think there is some bugs in String.
I'm useing svn 2284, just a week after 0.7.0.
a. Line 161 in CEGUIDynamicModule.cpp the formatted message returned by FormatMessageA is in CP_OEMCP, but CEGUI::String expects char* in ASCII regardless the locale. Such an assignment will cut every chinese char into 2 meaningless code points.
b. CEGUI::String::c_str() returns const char* in UTF-8, but as input parameter const char * is treated as ASCII. Thus a=b or a=b.data() is ok, but a=b.c_str() will result in a meaningless String. I prefer c_str() returns const utf8* or returns const char * but throw an exception if the string contains code points not in ASCII.
c. The worse is, std::string is also treated as in ASCII, so the assignment and auto-typecasting of std::string is sometimes a snare!
d. There is no support of wchar_t. On some platforms wchar_t is UTF-32, and some compilers take wchar_t and unsigned int as the same type, but even this, String has no assignment of utf32*, I don't know why.
e. On Windows, CEGUI::String accepts neither UTF-16LE wchar_t* nor CP_OEMCP char*(if CP_OEMCP is neither ASCII nor UTF-8). There is just no way to cooperate with other modules of the game at all! Or, I don't use Chinese strings at all? :(
f. Additionally, I wish CEGUI::String::data_type is configable. If some users of CEGUI prefer strings store in short int or char and accept all the disadvantage, why hard-code all the member data and functions with utf32?

lcy03406
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Fri Apr 24, 2009 01:18

Re: Something about CEGUI::String

Postby lcy03406 » Tue Oct 27, 2009 01:19

I'm sorry. The problem (a) will not happen, we have forced the message formated in English.

Now I have changed the value_type from int to wchar_t, and make String compatible with std::wstring.


Return to “CEGUI Library Development Discussion”

Who is online

Users browsing this forum: No registered users and 0 guests