UTF8 - Simple Library for Internationalization
Loading...
Searching...
No Matches
Character Classification Functions

Replacements for character classification functions. More...

Functions

bool utf8::isspace (char32_t r)
 Check if character is white space.
 
bool utf8::isspace (const char *p)
 Return true if character is blank(-ish).
 
bool utf8::isspace (std::string::const_iterator p)
 Return true if character is blank(-ish).
 
bool utf8::isblank (char32_t r)
 Check if character is space or tab.
 
bool utf8::isblank (const char *p)
 Check if character is space or tab.
 
bool utf8::isblank (std::string::const_iterator p)
 Check if character is space or tab.
 
bool utf8::isdigit (char32_t r)
 Check if character is a decimal digit (0-9)
 
bool utf8::isdigit (const char *p)
 Check if character is a decimal digit (0-9)
 
bool utf8::isdigit (std::string::const_iterator p)
 Check if character is a decimal digit (0-9)
 
bool utf8::isalnum (char32_t r)
 Check if character is an alphanumeric character (0-9 or A-Z or a-z)
 
bool utf8::isalnum (const char *p)
 Check if character is an alphanumeric character (0-9 or A-Z or a-z)
 
bool utf8::isalnum (std::string::const_iterator p)
 Check if character is an alphanumeric character (0-9 or A-Z or a-z)
 
bool utf8::isalpha (char32_t r)
 Check if character is an alphabetic character (A-Z or a-z)
 
bool utf8::isalpha (const char *p)
 Return true if character is an alphabetic character (A-Z or a-z)
 
bool utf8::isalpha (std::string::const_iterator p)
 Return true if character is an alphabetic character (A-Z or a-z)
 
bool utf8::isxdigit (char32_t r)
 Check if character is a hexadecimal digit (0-9 or A-F or a-f)
 
bool utf8::isxdigit (const char *p)
 Check if character is a hexadecimal digit (0-9 or A-F or a-f)
 
bool utf8::isxdigit (std::string::const_iterator p)
 Check if character is a hexadecimal digit (0-9 or A-F or a-f)
 
bool utf8::isupper (char32_t r)
 
bool utf8::isupper (const char *p)
 
bool utf8::isupper (std::string::const_iterator p)
 
bool utf8::islower (char32_t r)
 
bool utf8::islower (const char *p)
 
bool utf8::islower (std::string::const_iterator p)
 

Detailed Description

Replacements for character classification functions.

According to C standard, the is... family of functions have undefined behavior if the argument is outside the range of printable characters. These replacement functions are well-behaved for any input string.

The argument can be a char32_t character (rune), or a character pointer or a string iterator. Use them as in the following example:

//skip spaces in UTF-8 string
string s{ u8" \xA0日本語" };
auto p = s.begin ();
int blanks = 0;
while (p != s.end () && utf8::isspace (p))
{
blanks++;
utf8::next (p, s.end ());
}
assert (blanks == 2); //both space and "no-break space" are space characters
//...
bool isspace(char32_t r)
Check if character is white space.
Definition utf8.cpp:688

Function Documentation

◆ isalnum() [1/3]

bool utf8::isalnum ( char32_t  r)
inline

Check if character is an alphanumeric character (0-9 or A-Z or a-z)

Parameters
rcharacter to check
Returns
true if character is alphanumeric, false otherwise

◆ isalnum() [2/3]

bool utf8::isalnum ( const char *  p)
inline

Check if character is an alphanumeric character (0-9 or A-Z or a-z)

Parameters
ppointer to character to check
Returns
true if character is alphanumeric, false otherwise

◆ isalnum() [3/3]

bool utf8::isalnum ( std::string::const_iterator  p)
inline

Check if character is an alphanumeric character (0-9 or A-Z or a-z)

Parameters
ppointer to character to check
Returns
true if character is alphanumeric, false otherwise

◆ isalpha() [1/3]

bool utf8::isalpha ( char32_t  r)
inline

Check if character is an alphabetic character (A-Z or a-z)

Parameters
rcharacter to check
Returns
true if character is alphabetic, false otherwise

◆ isalpha() [2/3]

bool utf8::isalpha ( const char *  p)
inline

Return true if character is an alphabetic character (A-Z or a-z)

Parameters
ppointer to character to check
Returns
true if character is alphabetic, false otherwise

◆ isalpha() [3/3]

bool utf8::isalpha ( std::string::const_iterator  p)
inline

Return true if character is an alphabetic character (A-Z or a-z)

Parameters
ppointer to character to check
Returns
true if character is alphabetic, false otherwise

◆ isblank() [1/3]

bool utf8::isblank ( char32_t  r)

Check if character is space or tab.

Parameters
rcharacter to check
Returns
true if character is \t (0x09) or is in the "Space_Separator" (Zs) category, false otherwise.

See Unicode Character Database for a list of characters in the Zs (Space_Separator) category. The function adds HORIZONTAL_TAB (0x09 or '\t') to the space separator category for compatibility with standard isblank (char c) C function.

◆ isblank() [2/3]

bool utf8::isblank ( const char *  p)
inline

Check if character is space or tab.

Parameters
ppointer to character to check
Returns
true if character is \t (0x09) or is in the "Space_Separator" (Zs) category, false otherwise.

See Unicode Character Database for a list of characters in the Zs (Space_Separator) category. The function adds HORIZONTAL_TAB (0x09 or '\t') to the space separator category for compatibility with standard isblank (char c) C function.

◆ isblank() [3/3]

bool utf8::isblank ( std::string::const_iterator  p)
inline

Check if character is space or tab.

Parameters
ppointer to character to check
Returns
true if character is \t (0x09) or is in the "Space_Separator" (Zs) category, false otherwise.

See Unicode Character Database for a list of characters in the Zs (Space_Separator) category. The function adds HORIZONTAL_TAB (0x09 or '\t') to the space separator category for compatibility with standard isblank (char c) C function.

◆ isdigit() [1/3]

bool utf8::isdigit ( char32_t  r)
inline

Check if character is a decimal digit (0-9)

Parameters
rcharacter to check
Returns
true if character is a digit, false otherwise

◆ isdigit() [2/3]

bool utf8::isdigit ( const char *  p)
inline

Check if character is a decimal digit (0-9)

Parameters
ppointer to character to check
Returns
true if character is a digit, false otherwise

◆ isdigit() [3/3]

bool utf8::isdigit ( std::string::const_iterator  p)
inline

Check if character is a decimal digit (0-9)

Parameters
ppointer to character to check
Returns
true if character is a digit, false otherwise

◆ islower() [1/3]

bool utf8::islower ( char32_t  r)

Return true if character is a lowercase character

Parameters
rcharacter to check

◆ islower() [2/3]

bool utf8::islower ( const char *  p)

Return true if character is a lowercase character

Parameters
ppointer to character to check

◆ islower() [3/3]

bool utf8::islower ( std::string::const_iterator  p)
inline

Return true if character is a lowercase character

Parameters
ppointer to character to check

◆ isspace() [1/3]

bool utf8::isspace ( char32_t  r)

Check if character is white space.

Parameters
rcharacter to check
Returns
true if character is white space, false otherwise

Returns true if Unicode character has the "White_Space=yes" property in the Unicode Character Database

◆ isspace() [2/3]

bool utf8::isspace ( const char *  p)
inline

Return true if character is blank(-ish).

Parameters
ppointer to character to check
Returns
true if character is blank, false otherwise

Returns true if Unicode character has the "White_Space=yes" property in the Unicode Character Database

◆ isspace() [3/3]

bool utf8::isspace ( std::string::const_iterator  p)
inline

Return true if character is blank(-ish).

Parameters
ppointer to character to check
Returns
true if character is blank, false otherwise

Returns true if Unicode character has the "White_Space=yes" property in the Unicode Character Database

◆ isupper() [1/3]

bool utf8::isupper ( char32_t  r)

Return true if character is an uppercase character

Parameters
rcharacter to check

◆ isupper() [2/3]

bool utf8::isupper ( const char *  p)

Return true if character is an uppercase character

Parameters
ppointer to character to check

◆ isupper() [3/3]

bool utf8::isupper ( std::string::const_iterator  p)
inline

Return true if character is an uppercase character

Parameters
ppointer to character to check

◆ isxdigit() [1/3]

bool utf8::isxdigit ( char32_t  r)
inline

Check if character is a hexadecimal digit (0-9 or A-F or a-f)

Parameters
rcharacter to check
Returns
true if character is hexadecimal, false otherwise

◆ isxdigit() [2/3]

bool utf8::isxdigit ( const char *  p)
inline

Check if character is a hexadecimal digit (0-9 or A-F or a-f)

Parameters
ppointer to character to check
Returns
true if character is hexadecimal, false otherwise

◆ isxdigit() [3/3]

bool utf8::isxdigit ( std::string::const_iterator  p)
inline

Check if character is a hexadecimal digit (0-9 or A-F or a-f)

Parameters
ppointer to character to check
Returns
true if character is hexadecimal, false otherwise