WinFF / winff

Automatically exported from code.google.com/p/winff
215 stars 49 forks source link

fix bug that WinFF fail to encode in Windows CJK environment #235

Closed daxiaoming closed 1 year ago

daxiaoming commented 6 years ago

fix bug that WinFF fail to encode in Windows CJK environment (probably other locales too, since utf-8 codepage is used)

daxiaoming commented 6 years ago

The main problem is that TStringList.saveToFile() will create UTF-8 file. But WinFF's old logic will try to call UTF8ToConsole to convert the BAT file content to console encoding (might be latin1). Wrong encoding of BAT file will prevent ffmpeg from running.

The patch will use utf-8 codepage if you enable CHCP option. Thus WiFF will be able to encode media file(s) with filename that contains non-ascii character.

Tested in Lazarus 1.8.0, Win7SP1 x64, Simplified Chinese.

--- the following is Chinese version of above --- 很久以来,如果文件名或者目录名包含了非英文字符,windows下运行的 WinFF 都不能进行正常的编码 (CMD窗口乱码导致ffmpeg不能运行)。本 patch 修复了这个问题。 主要问题是 TStringList.saveToFile() 创建的是 UTF-8 编码的文件,而旧WinFF的逻辑是调用 UTF8ToConsole 把BAT文件内容转换为控制台窗口编码(估计是 latin1)。

请在 偏好设置里面的 MS Windows 分页里面勾选“使用CHCP来处理国际字符”。启用了CHCP后,WinFF 会生成正确的BAT文件,可以正常调用 ffmpeg进行媒体文件编码。

已在 Win7SP1 x64 简体中文环境下测试通过(使用 lazarus-1.8.0 编译)。

paulgevers commented 6 years ago

@daxiaoming awesome that you provide a solution for an extremely long standing issue (Issue #51)

However, I am not a user on Windows, so I can't verify and I would love other people to confirm that with this patch implemented, stuff works.

daxiaoming commented 6 years ago

@paulgevers please do verify thoroughly before accepting this PR, as I only have simplified Chinese environment.