WideCharToMultiByteFilter
Jump to navigation
Jump to search
WideCharToMultiByteFilter was developed during the discussion of intermediate filters. Though a learning tool, the filter is useful on Windows platforms. Filter related details can be found at Filter (Intermediate). The remainder of this topic discusses how to use the filter. 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