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.From: Oka Motofumi <[email protected]> Date: Wed, 30 May 2012 22:46:33 +0900 Subject: [PATCH] cmdutils.c: avoid converting filepath to UTF-8 for avisynth avisynth is a non-unicode application. if UTF-8 is used for input filepath, avisynth may not operate normally. --- cmdutils.c | 24 ++++++++++++++++++------ 1 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index bd07d2a..0b3606b 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -175,7 +175,7 @@ static int win32_argc = 0; static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) { char *argstr_flat; - wchar_t **argv_w; + wchar_t **argv_w, *avs_ext = NULL; int i, buffsize = 0, offset = 0; if (win32_argv_utf8) { @@ -191,8 +191,15 @@ static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) /* determine the UTF-8 buffer size (including NULL-termination symbols) */ for (i = 0; i < win32_argc; i++) - buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, - NULL, 0, NULL, NULL); + /* Avisynth is a non-unicode application. + If input filepath which includes multibyte-characters is converted + to UTF-8, avisynth will miss the valid filepath. */ + if ((avs_ext = wcsrchr(argv_w[i], L'.')) && wcscmp(avs_ext, L".avs") == 0) + buffsize += WideCharToMultiByte(CP_THREAD_ACP, 0, argv_w[i], -1, + NULL, 0, NULL, NULL); + else + buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, + NULL, 0, NULL, NULL); win32_argv_utf8 = av_mallocz(sizeof(char *) * (win32_argc + 1) + buffsize); argstr_flat = (char *)win32_argv_utf8 + sizeof(char *) * (win32_argc + 1);
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
