[FFmpeg-devel] [PATCH] avutil/log: in colored_fputs, convert string from utf8 to CP_ACP charset on Windows

Reimar Döffinger Reimar.Doeffinger at gmx.de
Thu Feb 20 08:28:54 CET 2014


On 19.02.2014, at 09:09, ZHOU Zehua <zhouzehuasx at gmail.com> wrote:
> From: ZHOU Zehua <zhouzehua at gmail.com>
> 
> The strings in ffmpeg are mostly in utf8 charset, but the default
> charset of Windows Console is not utf8. As a result, the log output is
> garbled. This commit adds code to convert string from utf8 to CP_ACP
> before printed on Windows.
> 
> Note: If the input string is not in utf8, the conversion is supposed to
> fail and the original input string will be printed.

I think this is questionable and actually break things.
For example if someone redirects the output to a file, they will get everything just in UTF-8 currently.
After this patch, they instead get the output in a messy mix of local code page (strings that are entirely representable in it) and UTF-8 (those that aren't and where the conversion fails).
As far as I can tell the proper way to do this is to use WriteConsoleW, but only if there is no redirection.
I can easily see that we might encounter a few unexpected issues with that though.


More information about the ffmpeg-devel mailing list