nu774 / fdkaac

command line encoder frontend for libfdk-aac
Other
260 stars 58 forks source link

In win32, change codepage from UTF-8 to ANSI #14

Closed John-He-928 closed 10 years ago

John-He-928 commented 10 years ago

In win32, change codepage from UTF-8 to ANSI. Fixes "file not found" with non-ASCII filenames in "cmd" console.

When typing or drag-and-drop in cmd console, ANSI encoding is used, not UTF-8.

nu774 commented 10 years ago

Fixes "file not found" with non-ASCII filenames in "cmd" console.

Cannot reproduce here.

When typing or drag-and-drop in cmd console, ANSI encoding is used, not UTF-8.

NO. UNICODE (UTF-16) is used. Try creating a file named ❤.wav, then drug & drop it into cmd console. You will see it. They are supported through UNICODE API with W suffix.

fdkaac fetches command line arguments by __wgetmainargs() function in MSVC runtime, which is UNICODE based, then converts them to UTF-8. Therefore, it not only supports characters in your ANSI locale but also supports UNICODE only characters such as ❤.

John-He-928 commented 10 years ago

Sorry, I made a mistake. I called fdkaac in my batch script, in which filenames are not quoted. It's not a problem about encoding.

What made me doubt about encoding is the error message. I specify a filename with non-ASCII characters, fdkaac prints error message with strange characters. image

aacenc_fprintf function should be the cause. String length to print to the console is calculated by ANSI based functions _vsnprintf and _vscprintf. If the message contains non-ASCII characters (e.g. filename), the length returned will be greater than the actual length in UTF-16 form, and uninitialized content in ws buffer is printed.

nu774 commented 10 years ago

Thanks for reporting, aacenc_fprintf() issue was fixed on https://github.com/nu774/fdkaac/commit/a79a11ef998649d87f8428b9d07f6e637905b292