Introduction
After doing endless string programming I got sick of doing string conversion and
so split CString into a UNICODE and ANSI version (CStringW
and CStringA
).
I replicated the WTL string class and replaced the internal data representation from
TCHAR
to wchar_t
for CStringW
and char
for CStringA
, modifying
all functions depending on the internal data representation.
The classes behave exactly like CString
. Just include "StringA.h" and "StringW.h" like you include "atlmisc.h". Even
_ATL_MIN_CRT
is supported.
It's the same like MFC 7.0 is doing it, which gave me the inspiration by the way.
If you want to see unicode strings while debugging, don't forget to switch on Tools/Options/Debug/Display unicode strings. Which is not enabled by default.
Additionally you shoud modify your Autoexp.dat file to see the content of CStringW and CStringA like you are used from CString.
Add these two lines into the section [AutoExpand]:
CStringW =<m_pchData,su>
CStringA =<m_pchData,s>
Example
#include "StringA.h"
#include "StringW.h"
CStringW sTestW( L"Test" );
CStringA sTestA( "Test" );
CStringW sConvertW = sTestA;
CStringA sConvertA = sTestW;
I couldn't test all functions and probably some constructors are missing. If you find an error or have a suggestion please feel free and add a message to the discussion.
I hope you'll like and use it.
Oskar