My Windows application calls a system command using _wpopen. This command produces a UTF8 response that I attempt to read using fgetws into a buffer of wchar_t. The problem is that the result in my buffer is not correct. There might be a problem with character widths as my buffer contains 12 characters where in UTF8 it should contain only 4. I use Microsoft Visual Studio 2010.
I have independently verified that the system command produces proper output. Thus, it is somehow the reading operation that messes up the encoding. What to do? Thank you!