4 #ifndef INCLUDED_RTL_CHARACTER_HXX
5 #define INCLUDED_RTL_CHARACTER_HXX
14 #if defined LIBO_INTERNAL_ONLY
15 #include <type_traits>
44 #if defined LIBO_INTERNAL_ONLY
46 bool isAscii(
signed char) =
delete;
48 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
bool>
51 return isAscii(sal_uInt32(code));
67 return code >=
'a' && code <=
'z';
70 #if defined LIBO_INTERNAL_ONLY
74 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
bool>
93 return code >=
'A' && code <=
'Z';
96 #if defined LIBO_INTERNAL_ONLY
100 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
bool>
122 #if defined LIBO_INTERNAL_ONLY
125 template <
typename T>
126 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
bool>
145 return code >=
'0' && code <=
'9';
148 #if defined LIBO_INTERNAL_ONLY
151 template <
typename T>
152 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
bool>
174 #if defined LIBO_INTERNAL_ONLY
177 template <
typename T>
178 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
bool>
197 return isAsciiDigit(code) || (code >=
'A' && code <=
'F');
200 #if defined LIBO_INTERNAL_ONLY
203 template <
typename T>
204 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
bool>
226 #if defined LIBO_INTERNAL_ONLY
229 template <
typename T>
230 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
bool>
248 return code >=
'0' && code <=
'7';
251 #if defined LIBO_INTERNAL_ONLY
254 template <
typename T>
255 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
bool>
274 return code ==
' ' || code ==
'\f' || code ==
'\n' || code ==
'\r' || code ==
'\t'
278 #if defined LIBO_INTERNAL_ONLY
281 template <
typename T>
282 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
bool>
303 #if defined LIBO_INTERNAL_ONLY
306 template <
typename T>
307 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
329 #if defined LIBO_INTERNAL_ONLY
332 template <
typename T>
333 inline constexpr std::enable_if_t<std::is_integral_v<T> &&
sizeof(T) <=
sizeof(sal_uInt32),
364 sal_uInt32
const surrogatesHighFirst = 0xD800;
365 sal_uInt32
const surrogatesHighLast = 0xDBFF;
366 sal_uInt32
const surrogatesLowFirst = 0xDC00;
367 sal_uInt32
const surrogatesLowLast = 0xDFFF;
382 return code >= detail::surrogatesHighFirst && code <= detail::surrogatesLowLast;
396 return code >= detail::surrogatesHighFirst && code <= detail::surrogatesHighLast;
410 return code >= detail::surrogatesLowFirst && code <= detail::surrogatesLowLast;
424 assert(code >= 0x10000);
425 return static_cast<sal_Unicode>(((code - 0x10000) >> 10) | detail::surrogatesHighFirst);
439 assert(code >= 0x10000);
440 return static_cast<sal_Unicode>(((code - 0x10000) & 0x3FF) | detail::surrogatesLowFirst);
457 return ((high - detail::surrogatesHighFirst) << 10) + (low - detail::surrogatesLowFirst)
476 assert(output != NULL);
SAL_CONSTEXPR bool isAscii(sal_uInt32 code)
Check for ASCII character.
Definition: character.hxx:38
SAL_CONSTEXPR bool isAsciiAlpha(sal_uInt32 code)
Check for ASCII alphabetic character.
Definition: character.hxx:116
SAL_CONSTEXPR bool isUnicodeCodePoint(sal_uInt32 code)
Check for Unicode code point.
Definition: character.hxx:28
SAL_CONSTEXPR sal_Int32 compareIgnoreAsciiCase(sal_uInt32 code1, sal_uInt32 code2)
Compare two characters ignoring ASCII case.
Definition: character.hxx:353
SAL_CONSTEXPR bool isUnicodeScalarValue(sal_uInt32 code)
Check for Unicode scalar value.
Definition: character.hxx:498
SAL_CONSTEXPR bool isAsciiUpperCase(sal_uInt32 code)
Check for ASCII upper case character.
Definition: character.hxx:90
sal_uInt16 sal_Unicode
Definition: types.h:103
SAL_CONSTEXPR std::size_t splitSurrogates(sal_uInt32 code, sal_Unicode *output)
Split a Unicode code point into UTF-16 code units.
Definition: character.hxx:473
SAL_CONSTEXPR bool isSurrogate(sal_uInt32 code)
Check for surrogate.
Definition: character.hxx:379
SAL_CONSTEXPR bool isAsciiDigit(sal_uInt32 code)
Check for ASCII digit character.
Definition: character.hxx:142
SAL_CONSTEXPR sal_Unicode getLowSurrogate(sal_uInt32 code)
Get low surrogate half of a non-BMP Unicode code point.
Definition: character.hxx:436
SAL_CONSTEXPR bool isAsciiLowerCase(sal_uInt32 code)
Check for ASCII lower case character.
Definition: character.hxx:64
SAL_CONSTEXPR bool isAsciiCanonicHexDigit(sal_uInt32 code)
Check for ASCII canonic hexadecimal digit character.
Definition: character.hxx:194
SAL_CONSTEXPR sal_Unicode getHighSurrogate(sal_uInt32 code)
Get high surrogate half of a non-BMP Unicode code point.
Definition: character.hxx:421
#define SAL_CONSTEXPR
C++11 "constexpr" feature.
Definition: types.h:384
SAL_CONSTEXPR sal_uInt32 combineSurrogates(sal_uInt32 high, sal_uInt32 low)
Combine surrogates to form a code point.
Definition: character.hxx:453
SAL_CONSTEXPR bool isLowSurrogate(sal_uInt32 code)
Check for low surrogate.
Definition: character.hxx:407
SAL_CONSTEXPR bool isAsciiOctalDigit(sal_uInt32 code)
Check for ASCII octal digit character.
Definition: character.hxx:245
SAL_CONSTEXPR bool isAsciiWhiteSpace(sal_uInt32 code)
Check for ASCII white space character.
Definition: character.hxx:271
SAL_CONSTEXPR sal_uInt32 toAsciiUpperCase(sal_uInt32 code)
Convert a character, if ASCII, to upper case.
Definition: character.hxx:297
SAL_CONSTEXPR bool isHighSurrogate(sal_uInt32 code)
Check for high surrogate.
Definition: character.hxx:393
SAL_CONSTEXPR bool isAsciiAlphanumeric(sal_uInt32 code)
Check for ASCII alphanumeric character.
Definition: character.hxx:168
SAL_CONSTEXPR sal_uInt32 toAsciiLowerCase(sal_uInt32 code)
Convert a character, if ASCII, to lower case.
Definition: character.hxx:323
SAL_CONSTEXPR bool isAsciiHexDigit(sal_uInt32 code)
Check for ASCII hexadecimal digit character.
Definition: character.hxx:220