In our app, our other modules use std::wstring, and compile them in UNICODE mode, we wish cegui's utf8-string support configure, so cegui may use our std::wstring...
can support?
3q!
wish support configure for utf8 string
Moderators: CEGUI MVP, CEGUI Team
- scriptkid
- Home away from home

- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Hi,
(i don't completely understand your first line, but here we go):
If you are looking for a conversion of your wstring to a CEGUI string (or at least to utf8) you can look at a piece of code from the layout editor. There we do the same for converting a wxString (wxWwidgets unicode string) into a CEGUI string:
As you can see, the trick is a Wide character to Multibyte character conversion (cWC2MB). On windows, you can use the WideCharToMultiByte function. I found this thread pretty usefull after a quick glance:
http://www.experts-exchange.com/Program ... 46903.html
If this is not what you meant, just reply again please
HTH!
(i don't completely understand your first line, but here we go):
If you are looking for a conversion of your wstring to a CEGUI string (or at least to utf8) you can look at a piece of code from the layout editor. There we do the same for converting a wxString (wxWwidgets unicode string) into a CEGUI string:
Code: Select all
/** Converts a wxWidgets string into a CEGUI string, Unicode proof.*/
static CEGUI::String ToCEGUIString(const wxString& str)
{
const wxWCharBuffer buf = wxConvLibc.cWX2WC(str.c_str());
return CEGUI::String( (const CEGUI::utf8*)(wxConvUTF8.cWC2MB(buf.data()).data() ) );
}
As you can see, the trick is a Wide character to Multibyte character conversion (cWC2MB). On windows, you can use the WideCharToMultiByte function. I found this thread pretty usefull after a quick glance:
http://www.experts-exchange.com/Program ... 46903.html
If this is not what you meant, just reply again please
HTH!
scriptkid wrote:Hi,
(i don't completely understand your first line, but here we go):
If you are looking for a conversion of your wstring to a CEGUI string (or at least to utf8) you can look at a piece of code from the layout editor. There we do the same for converting a wxString (wxWwidgets unicode string) into a CEGUI string:Code: Select all
/** Converts a wxWidgets string into a CEGUI string, Unicode proof.*/
static CEGUI::String ToCEGUIString(const wxString& str)
{
const wxWCharBuffer buf = wxConvLibc.cWX2WC(str.c_str());
return CEGUI::String( (const CEGUI::utf8*)(wxConvUTF8.cWC2MB(buf.data()).data() ) );
}
As you can see, the trick is a Wide character to Multibyte character conversion (cWC2MB). On windows, you can use the WideCharToMultiByte function. I found this thread pretty usefull after a quick glance:
http://www.experts-exchange.com/Program ... 46903.html
If this is not what you meant, just reply again please
HTH!
hehe...,sorry,my poor english!! chinese english!
You understand my meant,..., but i don't wish to convert wide string to CEGUI string, i wish to CEGUI support std::wstring directly by some condition compile, i.e.
#ifndef CEGUIString
#define CEGUIString CEGUI::String
#endif
so, i can define my string calss before include "cegui.h".
#define CEGUIString std::wstring
#include "cegui.h"
or i only modefy the marco define in the cegui.h file:
#define CEGUIString std::wstring
and, compile CEGUI, thus CEGUI use std::wstring directly, keep compatible with our modules.
- scriptkid
- Home away from home

- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Hi,
okay i see what you really meant now
My first guess is that your idea involves slightly more then an #ifdef. You can indeed put the #ifdef in the CEGUIString.h file, thereby skipping the declaration of the String class, and then say something like:
(I'd prefer typedef over a define).
However, the Cegui String has methods which might not be available in the std::wstring, or are at least named differently.
Another idea is to inherit the Cegui string from the std::wstring, and implement the methods by calling the wstring versions, thereby not breaking any client code.
But keep in mind: i am not the author of the library, but from what i have seen of cegui so far, is that the String class is used often. Besides, i think that the reason for the Cegui String is that it's 'real' unicode, where the wstring isn't. So be very carefull with hacking it
Btw. what is your problem with a conversion? Do you have serious performance requirements or something?
Good luck
okay i see what you really meant now
My first guess is that your idea involves slightly more then an #ifdef. You can indeed put the #ifdef in the CEGUIString.h file, thereby skipping the declaration of the String class, and then say something like:
Code: Select all
typedef std::wstring CEGUI::String;(I'd prefer typedef over a define).
However, the Cegui String has methods which might not be available in the std::wstring, or are at least named differently.
Another idea is to inherit the Cegui string from the std::wstring, and implement the methods by calling the wstring versions, thereby not breaking any client code.
But keep in mind: i am not the author of the library, but from what i have seen of cegui so far, is that the String class is used often. Besides, i think that the reason for the Cegui String is that it's 'real' unicode, where the wstring isn't. So be very carefull with hacking it
Btw. what is your problem with a conversion? Do you have serious performance requirements or something?
Good luck
Return to “Bug Reports, Suggestions, Feature Requests”
Who is online
Users browsing this forum: No registered users and 7 guests
