]> git.ipfire.org Git - thirdparty/curl.git/commit
tool_cb_wrt: fix invalid unicode for windows console
authorJay Satiro <raysatiro@yahoo.com>
Tue, 4 Apr 2023 09:10:52 +0000 (05:10 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Tue, 1 Aug 2023 07:28:12 +0000 (03:28 -0400)
commitaf3f4e419b9f339790de281c871640a773c391c0
tree11d91462389f593b47b87a10be6b695a6a13c01d
parent0b947e8ca2c23146375ba61281e530c843a47fcb
tool_cb_wrt: fix invalid unicode for windows console

- Suppress an incomplete UTF-8 sequence at the end of the buffer.

- Attempt to reconstruct incomplete UTF-8 sequence from prior call(s)
  in current call.

Prior to this change, in Windows console UTF-8 sequences split between
two or more calls to the write callback would cause invalid "replacement
characters" U+FFFD to be printed instead of the actual Unicode
character. This is because in Windows only UTF-16 encoded characters are
printed to the console, therefore we convert the UTF-8 contents to
UTF-16, which cannot be done with partial UTF-8 sequences.

Reported-by: Maksim Arhipov
Fixes https://github.com/curl/curl/issues/9841
Closes https://github.com/curl/curl/pull/10890
src/tool_cb_hdr.c
src/tool_cb_wrt.c
src/tool_operate.c
src/tool_sdecls.h