I'm using the Win32 API MultiByteToWideChar()
function to convert any encoding into Wide characters. The issue is, I will be streaming data in. For example, I could read a chunk of fixed width data into a buffer, and then call that function.
The issue is when that chunk is in between a multi-byte character, then MultiByteToWideChar()
would fail.
My question is, how do I get the index of the last full character in the buffer?
I suppose I could try again with a shortened buffer every single time the function fails, but with large buffers this is extremely inefficient.
I wanted to do this because I tried out both ICONV and ICU. ICONV was slower than the .NET decoder class, so I implemented that in C++. Then, I found out that ICU was faster than the .NET decoder. Then, I figured out MultiByteToWideChar()
is the fastest.