Thread: [Cppunit-devel] Unicode
Brought to you by:
blep
From: Baptiste L. <bl...@cl...> - 2001-05-18 21:23:52
|
Michael Arnoldus gracefuly sent me a unicode version of CppUnitW 1.2. The change required to add unicode support in cppunit are: * having alias to std::string or std::wstring depending on weither we are compiling for unicode or not. This also apply to ostrstream, cerr, and cout. Michael did it that as follow: #ifdef _UNICODE #define _tstring wstring #else #define _tstring string #endif This could probably be done using typedef and creating string in CppUnit namespace too: #ifdef _UNICODE typedef std::wstring string #else typedef std::string string #endif * having a macro _T which make the specified string unicode when needed: std::_tstring( _T( "Unknown" ) ) * adding a function ustring( const char *) to estring.h to construct a unicode string from a const char *string. This one is a problem for portability. Mapping from "char *" to unicode is done using WIN32 API. So how is that done on unix. Is there a single API for all Unix to do the mapping ? (I know that QT support unicode and is portable, but not how difficult it is to achieve on Unix) * adding new configuration to projects setting for VC++ (Michael let me know if I forgot something) Note for Unix developper: The _t thingy is a win32 idiom. We have a tchar.h header which provides all string function with such a prefix, aliasing to either single byte character string or unicode character string function depending on _UNICODE symbol. Is there such an idiom for Unix ? Here is the "Unicode TODO" list that I can see for now: - make a new header file which contains all stuffs relating to unicode (macros, typedef...) - replace character dependent object used in cppunit with those defined in the previous header - add the ustring function. I'm can do all those stuffs but we need to define the specific (header file name, define/typedef, alias name, _T name...). Baptiste. --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Author of The Text Reformatter, a tool for fanfiction readers and writers. Language: English, French (Well, I'm French). |
From: Michael A. <ch...@mu...> - 2001-05-19 13:47:48
|
You forgot one thing: Previously the standard library method ' const char* = std::exception::what()' was used, but as you can see it can only return = a single byte charactar string, not unicode (a designflaw if you ask = me). I have therefore added a method '_tstring Exception::uwhat()', to = return exception strings in unicode. Enjoy. Michael Arnoldus ----- Original Message -----=20 From: "Baptiste Lepilleur" <bl...@cl...> To: "Cpp Unit Develpment Mailing List" = <cpp...@li...> Sent: Friday, May 18, 2001 11:33 PM Subject: [Cppunit-devel] Unicode > Michael Arnoldus gracefuly sent me a unicode version of CppUnitW 1.2. >=20 > The change required to add unicode support in cppunit are: >=20 > * having alias to std::string or std::wstring depending on weither we = are > compiling for unicode or not. This also apply to ostrstream, cerr, and = cout. >=20 > Michael did it that as follow: >=20 > #ifdef _UNICODE > #define _tstring wstring > #else > #define _tstring string > #endif >=20 > This could probably be done using typedef and creating string in = CppUnit > namespace too: >=20 > #ifdef _UNICODE > typedef std::wstring string > #else > typedef std::string string > #endif >=20 > * having a macro _T which make the specified string unicode when = needed: > std::_tstring( _T( "Unknown" ) ) >=20 > * adding a function ustring( const char *) to estring.h to construct a > unicode string from a const char *string. > This one is a problem for portability. Mapping from "char *" to = unicode is > done using WIN32 API. > So how is that done on unix. Is there a single API for all Unix to = do the > mapping ? (I know that QT support unicode and is portable, but not how > difficult it is to achieve on Unix) >=20 > * adding new configuration to projects setting for VC++ >=20 > (Michael let me know if I forgot something) >=20 > Note for Unix developper: > The _t thingy is a win32 idiom. We have a tchar.h header which = provides all > string function with such a prefix, aliasing to either single byte = character > string or unicode character string function depending on _UNICODE = symbol. >=20 > Is there such an idiom for Unix ? >=20 > Here is the "Unicode TODO" list that I can see for now: > - make a new header file which contains all stuffs relating to unicode > (macros, typedef...) > - replace character dependent object used in cppunit with those = defined in > the previous header > - add the ustring function. >=20 > I'm can do all those stuffs but we need to define the specific (header = file > name, define/typedef, alias name, _T name...). >=20 > Baptiste. > --- > Baptiste Lepilleur <gai...@fr...> = http://gaiacrtn.free.fr/index.html > Author of The Text Reformatter, a tool for fanfiction readers and = writers. > Language: English, French (Well, I'm French). >=20 >=20 > _______________________________________________ > Cppunit-devel mailing list > Cpp...@li... > http://lists.sourceforge.net/lists/listinfo/cppunit-devel >=20 >=20 >=20 |
From: Baptiste L. <bl...@cl...> - 2001-05-23 18:30:04
|
> * adding a function ustring( const char *) to estring.h to construct a > unicode string from a const char *string. > This one is a problem for portability. Mapping from "char *" to unicode is > done using WIN32 API. > So how is that done on unix. Is there a single API for all Unix to do the > mapping ? (I know that QT support unicode and is portable, but not how > difficult it is to achieve on Unix) I looked at how it was done in QT 2.3.0 QString class (http://www.trolltech.no, worth looking at if you don't know what it is ;-) ). If I got the code right, latin1 is converted to unicode by casting the char to a wchar_t. Since the most common use for this conversion would be for RTTI names and standard exception messages, they likely would be latin1. So we could implements this simple conversion for Unix. Did I mess up real hard reading the code ? What do you think of this solution ? Baptiste. --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Author of The Text Reformatter, a tool for fanfiction readers and writers. Language: English, French (Well, I'm French). |