dtl


Unicode Wide Character Support in DTL

When speaking about support for unicode, there are two distinct pieces of functionality that are often requested:

The support for reading and writing wide character strings was generously donated by Dale Peakall. To read/write wide character strings we now support binding to wstring class member fields. In addition, we have upgraded the variant_row class to automatically detect wide character columns in a database and represent these columns using a wstring.

The support for full-blown wide character mode is more involved. To enable unicode mode you will need to set two pre-processor defines called "UNICODE" and "_UNICODE"; these defines can be found the in the example_unicode project. To implement wide character support, we have taken a windows-ish type approach and defined the following typedefs and macros: (actually, under Windows we include the TCHAR.H header file which defines more than we need, but here we list here only what the the program requires other than implementation details in clib_fwd.cpp)

Finally, we have changed all the functions in the library that accept and return string arguments to now take a tstring instead. For example, if we request a find from an IndexedDBView using an alternate key, i.e. find_AK(tstring &s, key &k), the field is now represented as a tstring. This means that in UNICODE mode we now have the capability to fully support wide field names.

There is one final wrinkle worth noting about how we implemented the UNICODE version which is our exception structure. All of our exceptions inherit from std::exception which provides a what() method to extract the exception message. Unfortunately, this what() method is standardized to return a char *, which is unsatisfactory if one wants to retrieve wide character error messages. For this reason, all of our exception classes now have an additional method called THCAR *twhat() which returns a char * in ASCII mode and a wchar_t * in unicode mode.


[DTL Home]

Copyright 2002, Michael Gradman and Corwin Joy.

Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Corwin Joy and Michael Gradman make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

SourceForge Logo

This site written using the ORB. [The ORB]