Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert to
unsigned char
before invoking std::isprint()
.
As the documentation states, the caller must check that the input character in [`std::isprint()`](https://en.cppreference.com/w/cpp/string/byte/isprint) is a valid `unsigned char`: > Like all other functions from `<cctype>`, the behavior of > `std::isprint` is undefined if the argument's value is neither > representable as `unsigned char` nor equal to `EOF`. To use these > functions safely with plain `char`s (or `signed char`s), the argument > should first be converted to `unsigned char`: > > ```cpp > bool my_isprint(char ch) > { > return std::isprint(static_cast<unsigned char>(ch)); > } > ``` The aforementioned undefined behavior manifests as a debug assertion when compiled with MSVC: ![image](https://github.com/user-attachments/assets/144e3573-f53c-4e89-a0cd-d615caa2749e) The affected functionality was introduced in #122. Fixes #173.
- Loading branch information