Re: [PATCH 5/5] Win32: Thread-safe windows console output
- From
Peter Krefting <peter@softwolves.pp.se>
- Date
- Jun 6, 2014, 21:29 UTC
- Message-ID
- <alpine.DEB.2.00.1406062224530.17391@ds9.cixit.se>
- In-Reply-To
- <1402062173-9602-6-git-send-email-kasal@ucw.cz>
Stepan Kasal:
> + /* only called from console_thread, so a static buffer will do */ > + static wchar_t wbuf[2 * BUFFER_SIZE + 1];
Wouldn't BUFFER_SIZE + 1 (or even BUFFER_SIZE) do here? If you convert from up to BUFFER_SIZE octets of UTF-8 input, you should never get back more than BUFFER_SIZE code units of UTF-16 output. Worst case would be ASCII, which is one UTF-16 code unit per UTF-8 octet, everything else is less (non-BMP is four UTF-8 octets mapping to two UTF-16 code units).
-- \\// Peter - http://www.softwolves.pp.se/