Commit 814b2a21 authored by Max Kellermann's avatar Max Kellermann

util/CharUtil: add IsNonPrintableASCII()

Prepare to fix cc72ceb3
parent 6423670e
/* /*
* Copyright (C) 2011-2017 Max Kellermann <max.kellermann@gmail.com> * Copyright 2011-2020 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -70,12 +70,29 @@ IsWhitespaceFast(const char ch) noexcept ...@@ -70,12 +70,29 @@ IsWhitespaceFast(const char ch) noexcept
return IsWhitespaceOrNull(ch); return IsWhitespaceOrNull(ch);
} }
/**
* Is this a non-printable ASCII character? Returns false for
* non-ASCII characters.
*
* Note that this is not the opposide of IsNonPrintableASCII().
*/
constexpr bool constexpr bool
IsPrintableASCII(char ch) noexcept IsPrintableASCII(char ch) noexcept
{ {
return (signed char)ch >= 0x20; return (signed char)ch >= 0x20;
} }
/**
* Is this a non-printable character? Returns false for non-ASCII characters.
*
* Note that this is not the opposide of IsPrintableASCII()
*/
constexpr bool
IsNonPrintableASCII(char ch) noexcept
{
return (unsigned char)ch < 0x20;
}
constexpr bool constexpr bool
IsDigitASCII(char ch) noexcept IsDigitASCII(char ch) noexcept
{ {
......
/* /*
* Copyright 2011-2019 Max Kellermann <max.kellermann@gmail.com> * Copyright 2011-2020 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -62,12 +62,30 @@ IsWhitespaceFast(const wchar_t ch) noexcept ...@@ -62,12 +62,30 @@ IsWhitespaceFast(const wchar_t ch) noexcept
return IsWhitespaceOrNull(ch); return IsWhitespaceOrNull(ch);
} }
/**
* Is this a non-printable ASCII character? Returns false for
* non-ASCII characters.
*
* Note that this is not the opposide of IsNonPrintableASCII().
*/
constexpr bool constexpr bool
IsPrintableASCII(wchar_t ch) noexcept IsPrintableASCII(wchar_t ch) noexcept
{ {
return IsASCII(ch) && ch >= 0x20; return IsASCII(ch) && ch >= 0x20;
} }
/**
* Is this a non-printable character? Returns false for non-ASCII
* characters.
*
* Note that this is not the opposide of IsPrintableASCII()
*/
constexpr bool
IsNonPrintableASCII(wchar_t ch) noexcept
{
return (unsigned)ch < 0x20;
}
constexpr bool constexpr bool
IsDigitASCII(wchar_t ch) noexcept IsDigitASCII(wchar_t ch) noexcept
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment