Skip to content

Commit

Permalink
Revert "use isprint"
Browse files Browse the repository at this point in the history
This reverts commit 0cfd19a.
  • Loading branch information
neheb committed Feb 20, 2025
1 parent 499413c commit 526d456
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bmffimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ std::string BmffImage::toAscii(uint32_t n) {
// show 0 as _
std::replace(result.begin(), result.end(), '\0', '_');
// show non 7-bit printable ascii as .
auto f = [](unsigned char c) { return !std::isprint(c); };
auto f = [](char c) { return c < 32 || c > 126; };
std::replace_if(result.begin(), result.end(), f, '.');
return result;
}
Expand Down
5 changes: 3 additions & 2 deletions src/image_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ template <typename T>
std::ostream& operator<<(std::ostream& stream, const binaryToStringHelper<T>& binToStr) {
for (size_t i = 0; i < binToStr.buf_.size(); ++i) {
auto c = static_cast<int>(binToStr.buf_.at(i));
if (c != 0 || i != binToStr.buf_.size() - 1) {
if (!std::isprint(static_cast<unsigned char>(c))) {
const bool bTrailingNull = c == 0 && i == binToStr.buf_.size() - 1;
if (!bTrailingNull) {
if (c < ' ' || c >= 127) {
c = '.';
}
stream.put(static_cast<char>(c));
Expand Down

0 comments on commit 526d456

Please sign in to comment.