diff --git a/ascii.hpp b/ascii.hpp index b2cf627c..973fc253 100644 --- a/ascii.hpp +++ b/ascii.hpp @@ -131,6 +131,19 @@ namespace cruft::ascii { } + ///------------------------------------------------------------------------ + /// Convert an ASCII character into a lower case character if it is upper + /// case, else return it unchanged. + /// + /// If you know the character is always upper case then prefer to_lower. + constexpr inline + char + try_lower (char c) noexcept + { + return is_upper (c) ? to_lower (c) : c; + } + + /////////////////////////////////////////////////////////////////////////// /// Returns true if the supplied ASCII character is whitespace. constexpr inline