]> _ Git - termbox2.git/commit
add built-in replacements for `iswprint(3)` and `wcwidth(3)`
authorAdam Saponara <as@php.net>
Mon, 21 Apr 2025 04:34:59 +0000 (00:34 -0400)
committerAdam <as@php.net>
Wed, 23 Apr 2025 02:33:32 +0000 (22:33 -0400)
commita6060a508f027f0efaed2c9943768d08347fbc68
tree44be154034e3f913ad74ce6c6258ae53777007d3
parent19ad32d2189e00411d39aa6363b9b9fd54daff91
add built-in replacements for `iswprint(3)` and `wcwidth(3)`

in b075ddd, we added an `iswprint` check to prevent untrusted input
from garbling the terminal. `iswprint` is locale-dependent, so if the
caller did not `setlocale` to a UTF-8 `LC_CTYPE`, the check would
fail. this affected several library users.

termbox has always had built-in support for converting between UTF-8
and 32-bit codepoints (i.e., replacements for `wcrtomb(3)` and
`mbrtowc(3)`). this patch adds built-in support for `iswprint` and
`wcwidth` as well, which makes the entire library Unicode compatible
independent of locale.

a compile-time option to use the libc versions is supported.
termbox2.h
tests/test_prepend.php
tests/test_wcwidth/expected.ansi [new file with mode: 0644]
tests/test_wcwidth/test.php [new file with mode: 0755]