here is the problem. The system is English Windows 10 Enterprise of version 22H2. An excutable file locates in a path specified by an English-Chinese mixed string, i.e., C:some english wordssome chinese charactorsFILENAME.exe.
To manipulate this FILENAME.exe, I get the path of it by using a Window API GetModuleFileName, and store the string in a wchar_t array, named pathW. then tranform the string into a UTF-8 one, named pathU8, by using another Window API WideCharToMultiByte with the first argument of CP_UTF8.
After the tramforming, the chinese charactors found garbled both in the watch window of visual stidio and a output console window, while in a correct form after writing it into a binary file and open the file to check it. This imply pathW was tranformed correctly, I guess.
But how to utilize this pathU8 with garbled chinese charactors? Passing it to the functions such as int _stat(pathU8, struct stat* const _Stat), int _access(pathU8, 0), all of them indicate the file does NOT exist!
liebealt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.