As far as I'm concerned you could try to use MultiByteToWideChar function with CP_UTF8.
C++: Reading an UTF-8 file with Win32 API
I have entering the file IO section of Win32 API. This time, I wanted to read file from.
Here is what I tried so far. This code outputs  ̄テᄄ ̄テᆱ ̄ツᄋ ̄ツᆱ instead of Japanese word ヨルシカ which is weird.
I know this problem, in this code, I didn't read the file as an UTF-8 file, instead I read the file as an ANSI file (256 characters).
So how can I read an UTF-8 file and then put the result in wchar_t array, using built-in Win32 API?
I want the readed character as single UTF-8 character. So each character in the buffer is UTF-8 character, not 256 character.
Windows development | Windows API - Win32
Developer technologies | C++
-
Jeanine Zhang-MSFT 11,356 Reputation points Microsoft External Staff2022-09-27T06:39:33.733+00:00
1 additional answer
Sort by: Most helpful
-
Guido Franzke 2,191 Reputation points2022-09-27T06:08:18.613+00:00 Hello,
have a look at this: read-unicode-utf-8-file-into-wstring
Regards, Guido