CUnicodeString Class

CUnicodeString is a replacement for CString. If you are one of these poor guys that has to write applications that use for example NetXxx functions and don't want to create a Unicode project, or use ANSI only functions from a unicode project or what ever, you always had to deal with MultiByteToWideChar and WideCharToMultibyte. Maybe you even have to play with native functions witch uses counted unicode strings (UNICODE_STRING) or LSA (LSAUNICODE_STRING). If you were in such situations and hated the fact that the MFC CString doesn't help you with these conversions, than you would love this little class...

CUnicodeString has all the functions that CString provides, so you can use it allmost everywhere where you use CString normaly. This class works internally only with Unicode strings. Every string assignment is converted to and stored as Unicode.

And the best of it: It's easy to use... :)

Example:


CUnicodeString cs;
WCHAR wc = L"My Wide String";
cs = wc;
CHAR ch = " needs a few ANSI chars to append";
cs += wc;
cs += " ";
LPSTR pstrMyText = cs;
LPWSTR pstrMyUnicodeText = cs;
cs.Empty();
cs = "MyUserName";
NetUserGetInfo(cs,....);
...
This class was written for a upcomming C++ library called SecLIB witch covers the whole NT-Security. This is one of the reasons why it internally works in Unicode. BTW: Using System API's in Unicode is allways faster in NT, because NT internally works also with Unicode only... :)

I hope you like it! :)

Alexander Keck
MCSE, MCDBA
(MCSD in progress....)

Downloads

Download source - 6 Kb