larsbs / id3v2lib

id3v2lib is a library written in C to read and edit id3 tags from mp3 files.
BSD 2-Clause "Simplified" License
128 stars 44 forks source link

On windows, in order to open file name with other language #18

Closed cxhawk closed 1 year ago

cxhawk commented 7 years ago

I added the following util method and replace all fopen with this:

ifdef _WINDOWS

include

endif

FILE tag_openFile(const char filename, const char* mode) {

ifdef _WINDOWS

WCHAR nameBuffer[256];
memset(nameBuffer, 0, 256*2);
MultiByteToWideChar(CP_UTF8, 0, filename, -1, nameBuffer, 256*2);
WCHAR modeBuffer[256];
memset(modeBuffer, 0, 256*2);
MultiByteToWideChar(CP_UTF8, 0, mode, -1, modeBuffer, 256*2);
return _wfopen(nameBuffer, modeBuffer);

else

return fopen(filename, mode);

endif

}