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

Michael Niedermayer michaelni
Thu Jun 25 13:59:34 CEST 2009


On Sat, Jun 20, 2009 at 11:56:37PM +0200, Kalle Blomster wrote:
> Hi.
> Currently, ffmpeg on Windows does not support opening files whose names 
> contain characters that cannot be expressed in the current locale, because 
> on Windows you can't pass UTF8 in a char* to _open() and have it work. You 
> have to convert the filename to UTF16 and use _wopen(), which takes a 
> wchar_t instead.
>
> I have attached a patch that attempts to solve the problem with a rather 
> ugly hack. It Works For Me(tm) under mingw at least. Comments are 
> appreciated.
>
> Regards,
> Karl Blomster

>  os_support.c |   17 +++++++++++++++++
>  os_support.h |    5 +++++
>  2 files changed, 22 insertions(+)
> 9afa6887f1f6998c37d75efaae5d589918dc752b  ffmpeg_win_utf8_paths.patch
> Index: libavformat/os_support.c
> ===================================================================
> --- libavformat/os_support.c	(revision 19242)
> +++ libavformat/os_support.c	(working copy)
> @@ -30,6 +30,23 @@
>  #include <sys/time.h>
>  #include "os_support.h"
>  
> +#ifdef HAVE_WIN_UTF8_PATHS
> +#define WIN32_LEAN_AND_MEAN
> +#include <windows.h>
> +#endif
> +
> +#ifdef HAVE_WIN_UTF8_PATHS
> +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

tabs are forbidden in svn
further reviews of this left to our windows maintaines

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090625/db16c333/attachment.pgp>



More information about the ffmpeg-devel mailing list