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
* modification, are permitted provided that the following conditions
......@@ -70,12 +70,29 @@ IsWhitespaceFast(const char ch) noexcept
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
IsPrintableASCII(char ch) noexcept
{
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
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
* modification, are permitted provided that the following conditions
......@@ -62,12 +62,30 @@ IsWhitespaceFast(const wchar_t ch) noexcept
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
IsPrintableASCII(wchar_t ch) noexcept
{
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
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