https://sourceware.org/bugzilla/show_bug.cgi?id=25713
--- Comment #27 from Torbjörn SVENSSON <torbjorn.svensson at st dot com> --- While the overall way to do it is covered in comment 26, there are some problems running MultiByteToWideChar. In the example in comment 26, it's assumed that the file path is encoded in UTF-8, or ASCII, but that's normally not the case on Windows. In Sweden, Windows is usually configured to use CP-850 and that would result in a garbage string after calling MultiByteToWideChar. By slightly modifying the example in comment 26 to loop over the arguments supplied to the application instead of looping over a fixed list of strings, the problems can be seen. For "foo.o", everything is fine, but not "foo.å" where "å" is a Swedish character that is part of CP-850: C:\dev\My_ÅÄÖ_Directory>chcp Active code page: 850 C:\dev\My_ÅÄÖ_Directory>c:\dev\pr25713.exe .\foo.o .\foo.å ==================================================== part: path = .\foo.o part: wpath = .\foo.o full: errno = 0 error = No error file: mode = w+b, ccs=UNICODE, fullPath = \\?\C:\dev\My_┼─Í_Directory\foo.o file: errno = 0 error = No error ==================================================== part: path = .\foo.Õ part: wpath = .\foo. full: errno = 42 error = Illegal byte sequence file: mode = w+b, ccs=UNICODE, fullPath = \\?\C:\dev\My_┼─Í_Directory\foo. file: errno = 42 error = Illegal byte sequence C:\dev\My_ÅÄÖ_Directory>dir Volume in drive C is Windows Volume Serial Number is 5E7C-4039 Directory of C:\dev\My_ÅÄÖ_Directory 2022-02-17 12:54 <DIR> . 2022-02-17 12:54 <DIR> .. 2022-02-17 12:54 0 foo.o 2022-02-17 12:54 0 foo.� 2 File(s) 0 bytes 2 Dir(s) 23 182 561 280 bytes free C:\dev\My_ÅÄÖ_Directory> The directory output above looks garbage, but it's actually okay and the reason is that CMD does not properly handle unicode. So, in other words: The conversion cannot assume UTF-8 (or ASCII) as the encoding for the user input. The above test was executed on Win10 20H2 with "Country or region" set to Sweden. -- You are receiving this mail because: You are on the CC list for the bug.