When I used opencv's API cvLoadImage(const char *filename, int iscolor)
It accepts const char *
as file name. When the file name is not ASCII-character, I tried to convert it to UTF8 string. It fails because fopen()
called in cvLoadImage()
can not interpret the characters of the file name literally as ASCII string. I may used _wfopen()
if tried to open file names, but if fopen()
is called in the third-party library, is there any method to handle this problem?
Thank you.
Use GetShortPathName. It will return an old (8.3) name for the file, which you should be able to convert to char*
, as it should not contain any non ASCII characters.
I've just tested it with some language specific characters and it worked as I described. I've successfully opened a file from C:\łęłęł\ąóąóą.tsttgbb
using fopen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With