Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fopen with unicode filename

I have to use a library that accepts file names as strings (const char*). Internally files are opened with fopen. Is there a way to make this library to accept unicode file name? Can I use WideCharToMultiByte to convert unicode names into utf before passing them to the library?

One possible (undesirable) solution is to change library interface (char* -> wchar_t*) and replace fopen with windows specific _wopen. Another solution is to use create symbolic links to files and pass those to the library, but it is limited to NTFS volumes only.

like image 489
quantum_well Avatar asked Nov 18 '25 15:11

quantum_well


1 Answers

Best way would be to rewrite the lib... Just my 2 Cents.

But if it is just about to open an existing file you can use GetShortPathName You find an existing discussion about this way here.

like image 54
xMRi Avatar answered Nov 20 '25 08:11

xMRi