[FFmpeg-devel] [PATCH] Support for UTF8 filenames on Windows

Reimar Döffinger Reimar.Doeffinger
Fri Jun 26 10:11:30 CEST 2009


On Fri, Jun 26, 2009 at 08:50:32AM +0100, M?ns Rullg?rd wrote:
> >>>> +int winutf8_open(const char *filename, int oflag, int pmode)
> >>>> +{
> >>>> +     wchar_t wfilename[MAX_PATH * 2];
> >>>> +
> >>>> +     if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wfilename,MAX_PATH) > 0)
> >>>> +             return _wopen(wfilename, oflag, pmode);
> >>>> +     else
> >>>> +             return open(filename, oflag, pmode);
> >>>> +}
> >>>> +#endif
> 
> What might cause MultiByteToWideChar() to fail?  What will plain
> open() do with such input?  Also, what is the value of MAX_PATH?
> It is probably a bad idea to silently truncate the filename at
> MAX_PATH characters.  This could turn an invalid name into the name of
> an existing file.

Since this is not speed critical IMO malloc a buffer of appropriate
size.
Probably something like 2*strlen(filename) + 8 or something like that
should work.



More information about the ffmpeg-devel mailing list