diff options
author | Oka Motofumi <chikuzen.mo@gmail.com> | 2013-06-21 22:57:03 +0900 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2013-06-22 16:41:43 -0400 |
commit | 81c5ceeda21186979a6f00d1611aa6a73f9b93a8 (patch) | |
tree | fc88e07fd353c6c6a9a52122590b575ec7a11472 | |
parent | 8bdbabfaa46989b1a0e82d2df0a27df32277294d (diff) | |
download | ffmpeg-81c5ceeda21186979a6f00d1611aa6a73f9b93a8.tar.gz |
avisynth: Make sure the filename passed to Avisynth is in the right code page
Avisynth is a non-unicode application and cannot accept UTF-8
characters. Therefore, the input filename should be converted to
the code page that it expects.
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
-rw-r--r-- | libavformat/avisynth.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index a5a4fcc6c9..35b66f1ff8 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -355,11 +355,22 @@ static int avisynth_open_file(AVFormatContext *s) { AviSynthContext *avs = (AviSynthContext *)s->priv_data; AVS_Value arg, val; int ret; +#ifdef _WIN32 + char filename_ansi[MAX_PATH * 4]; + wchar_t filename_wc[MAX_PATH * 4]; +#endif if (ret = avisynth_context_create(s)) return ret; +#ifdef _WIN32 + // Convert UTF-8 to ANSI code page + MultiByteToWideChar(CP_UTF8, 0, s->filename, -1, filename_wc, MAX_PATH * 4); + WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi, MAX_PATH * 4, NULL, NULL); + arg = avs_new_value_string(filename_ansi); +#else arg = avs_new_value_string(s->filename); +#endif val = avs_library->avs_invoke(avs->env, "Import", arg, 0); if (avs_is_error(val)) { av_log(s, AV_LOG_ERROR, "%s\n", avs_as_error(val)); |