WideCharToMultiByteFilter

From Crypto++ Wiki
Jump to navigation Jump to search

WideCharToMultiByteFilter is a filter which wraps Windows API function WideCharToMultiByteFilter. The counterpart to WideCharToMultiByteFilter is MultiByteToWideCharFilter.

Sample Programs

Crypto++ does not offer a WideStringSource, so the wide string is pushed in using a the StringSource or ArraySource. The StringSource or ArraySource must report the size in bytes and not wide characters.

Pipeline

wstring wide = L"WideCharToMultiByte Test";
string narrow;

// Need to send in byte count. A
// WideStringSource is probably a better idea
ArraySource( (const byte*) wide.data(),
    wide.size()*sizeof(wchar_t), true,
        new WideCharToMultiByteFilter(
    new StringSink( narrow )
    )
);

assert( "WideCharToMultiByte Test" == narrow );
cout << narrow << endl;

Downloads

WideCharToMultiByteFilter.zip - Crypto++ Filter sample wrapping Window's WideCharToMultiByte - 8KB