There is a 3rd lib only accept char* filename e.g. 3rdlib_func_name(char* file_name)
. Every things get wrong when I provide a filename in Chinese or Japanese.
Is there any way to make this lib open UNICODE filename? The program is running on Windows.
Thanks for your reply.
No, there isn't unless you can recompile it from modified source (a major undertaking). You might have better luck feeding the 3rd party library short filenames, like
AHDF76~4.DOC
; these filenames use ASCII. SeeGetShortPathName
.We has a similar problem too. Luckily there's a solution, though it's kinda tricky.
If the file/directory already exists - you may use the
GetShortPathName
function. The resulting "short" path name is guaranteed not to contain non-latin characters.GetShortPathNameW
(unicode version) to get the "short" path string.WideCharToMultiByte
).Now, if the file/directory doesn't exist yet - you may not obtain its short pathname. In such a case you should create it first.
You may try to convert the string to local code page:
Otherwise?
Blame windows for not supporting UTF-8
;-)