2012/5/30 Martin Storsjö <[email protected]>

> On Wed, 30 May 2012, Motofumi Oka wrote:
>
>  currentry, cmdutils convert all command lines to UTF-8 on windows.In
>> almost
>>
>> all cases, it works as expected, but this is harmful when inputting
>> avisynth
>> script.
>>
>
> This isn't the right place for this fix. All file names within libav* are
> supposed to be in utf8 - this could just as well be another app calling
> libavformat - that app would have to know who is going to use the file name.
>
> Instead, the code in libavformat/avisynth.c should convert the file name
> to the correct code page that it expects it to have, assuming that the
> input from lavf always is utf8.
>
> // Martin
> _______________________________________________
> libav-devel mailing list
> [email protected]
> https://lists.libav.org/mailman/listinfo/libav-devel
>
> then, how is this ?

diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 3b695a9..893ce3f 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -49,10 +49,15 @@ static int avisynth_read_header(AVFormatContext *s)
   DWORD id;
   AVStream *st;
   AVISynthStream *stream;
+  wchar_t filename_wchar[1024] = { 0 };
+  char filename_char[1024] = { 0 };

   AVIFileInit();

-  res = AVIFileOpen(&avs->file, s->filename, OF_READ|OF_SHARE_DENY_WRITE,
NULL);
+  MultiByteToWideChar(CP_UTF8, 0, s->filename, -1, filename_wchar, 1024);
+  WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wchar, -1, filename_char,
1024, NULL, NULL);
+
+  res = AVIFileOpen(&avs->file, filename_char,
OF_READ|OF_SHARE_DENY_WRITE, NULL);
   if (res != S_OK)
     {
       av_log(s, AV_LOG_ERROR, "AVIFileOpen failed with error %ld", res);
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to