I try to use fopen function in mingw. When fileNam...
# kotlin-native
a
I try to use fopen function in mingw. When fileName is ANSI string it works. But when fileName contains non-ansi symbols (cyrillic etc) I have a problem -
can't open file
For C I've found the solution -
OemToCharA
function but it doesn't work for me
Copy code
fileName = memScoped {
            val bytes = allocArray<CHARVar>(aFileName.length * 2)
            OemToCharA(aFileName, bytes)
            bytes.toKString()
        }
fileName contains wrong chars
p
Windows uses UTF-16 encoding internally, so standard
fopen
won’t work. You should use
_wfopen
with
MultiByteToWideChar()
to convert between UTF-8 and UTF-16.