ascii: add try_upper transform
This commit is contained in:
parent
050897389b
commit
f9aa13ad81
13
ascii.hpp
13
ascii.hpp
@ -117,6 +117,19 @@ namespace cruft::ascii {
|
||||
}
|
||||
|
||||
|
||||
///------------------------------------------------------------------------
|
||||
/// Convert an ASCII character into a upper case character if it is lower
|
||||
/// case, else return it unchanged.
|
||||
///
|
||||
/// If you know the character is always lower case then prefer to_upper.
|
||||
constexpr inline
|
||||
char
|
||||
try_upper (char c) noexcept
|
||||
{
|
||||
return is_lower (c) ? to_upper (c) : c;
|
||||
}
|
||||
|
||||
|
||||
///------------------------------------------------------------------------
|
||||
/// Converts an upper case ASCII character into a lower case character.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user