[PATCH] cmd: Properly handle multibyte characters in batch files.

Alexandre Julliard julliard at winehq.org
Tue Oct 16 13:45:07 CDT 2012


Akihiro Sagawa <sagawa.aki at gmail.com> writes:

> @@ -244,7 +244,8 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
>  
>    if (!WCMD_is_console_handle(h) && i != charsRead) {
>      /* Sets file pointer to the start of the next line, if any */
> -    filepos.QuadPart += i + 1 + (buf[i] == '\r' ? 1 : 0);
> +    INT bytes = WideCharToMultiByte(GetConsoleCP(), 0, buf, i, NULL, 0, NULL, NULL);
> +    filepos.QuadPart += bytes + 1 + (buf[i] == '\r' ? 1 : 0);

There's no guarantee that all characters would round-trip properly, this
should be based on the original multibyte length somehow.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list