How to open a file named UNICODE in Windows?
There is a 3rd library only accepting char * filename for example. 3rdlib_func_name(char* file_name)
... Everything goes wrong when I provide the file name in Chinese or Japanese.
Is there a way to make this lib open UNICODE file name? The program runs on Windows .
Thanks for your reply.
a source to share
We also have a similar problem. Fortunately, there is a solution, although it is quite difficult.
If the file / directory already exists, you can use the function GetShortPathName
. The resulting "short" pathname is guaranteed to contain no non-Latin characters.
- Call
GetShortPathNameW
(Unicode version) to get the "short" path string. - Convert short path to ANSI string (use
WideCharToMultiByte
). - Give the resulting ANSI string for a silly third party library.
Now, if the file / directory doesn't already exist, you might not get its short name. In this case, you must create it first.
a source to share
No, no, unless you can recompile it from the modified source (basic obligation). You might be in luck if you feed third-party library names with short filenames like AHDF76~4.DOC
; these filenames use ASCII. Cm GetShortPathName
.
a source to share