|
NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
Unicode码点包装类 更多...
#include <codepoint.hpp>
Public 成员函数 | |
| constexpr | codepoint () noexcept |
| 默认构造函数 | |
| constexpr | codepoint (uint32_t value) noexcept |
| 从uint32_t构造码点 | |
| constexpr | codepoint (const char32_t value) noexcept |
| 从char32_t构造码点 | |
| constexpr uint32_t | value () const noexcept |
| 获取码点的uint32_t值 | |
| constexpr char32_t | to_char32 () const noexcept |
| 获取码点的char32_t值 | |
| constexpr bool | is_replacement () const noexcept |
| 是否为替换符U+FFFD | |
| constexpr bool | is_ascii () const noexcept |
| 是否为ASCII字符(U+0000 ~ U+007F) | |
| constexpr bool | is_bmp () const noexcept |
| 是否位于基本多文种平面(BMP, U+0000 ~ U+FFFF) | |
| constexpr bool | is_supplementary () const noexcept |
| 是否为辅助平面字符(需要UTF-16代理对) | |
| constexpr bool | needs_surrogate_pair () const noexcept |
| 是否需要UTF-16代理对表示 | |
| constexpr size_t | utf8_length () const noexcept |
| UTF-8编码后的字节数 | |
| constexpr size_t | utf16_length () const noexcept |
| UTF-16编码后的码元数 | |
| void | append_to (string &result) const |
| 追加UTF-8编码到string | |
| void | append_to (u8string &result) const |
| 追加UTF-8编码到u8string | |
| void | append_to (u16string &result) const |
| 追加UTF-16编码到u16string | |
| void | append_to (u32string &result) const |
| 追加UTF-32编码到u32string | |
| void | append_to (wstring &result) const |
| 追加编码到wstring | |
静态 Public 成员函数 | |
| static NEFORCE_CONST_FUNCTION constexpr bool | is_high_surrogate (const char16_t c) noexcept |
| 检查字符是否为高代理项 | |
| static NEFORCE_CONST_FUNCTION constexpr bool | is_low_surrogate (const char16_t c) noexcept |
| 检查字符是否为低代理项 | |
| static NEFORCE_CONST_FUNCTION constexpr codepoint | combine_surrogates (const char16_t high, const char16_t low) noexcept |
| 组合高代理项和低代理项为完整的Unicode码点 | |
| static constexpr bool | is_valid_codepoint (const uint32_t v) noexcept |
| 检查码点值是否合法 | |
| static constexpr codepoint | replacement () noexcept |
| 构造替换符U+FFFD | |
| static constexpr codepoint | null () noexcept |
| 构造空字符U+0000 | |
| static codepoint | decode_utf8 (const byte_t *data, size_t &i, size_t len) noexcept |
| 从UTF-8字节流解码一个码点,并推进索引 | |
| template<typename T> | |
| static codepoint | decode_utf16 (const T *data, size_t &index, const size_t len, const bool need_swap) noexcept |
| 从UTF-16序列解码一个码点,并推进索引 | |
| static constexpr codepoint | from_utf32 (char32_t value) noexcept |
| 从UTF-32值直接构造码点 | |
静态 Public 属性 | |
| static constexpr uint32_t | REPLACEMENT_VALUE = 0xFFFD |
| Unicode 替换符 U+FFFD | |
| static constexpr uint32_t | MAX_VALUE = 0x10FFFF |
| Unicode 最大合法码点 | |
Unicode码点包装类
封装一个经过验证的Unicode码点(U+0000 ~ U+10FFFF,排除代理项)。 非法值在构造时自动替换为U+FFFD(替换字符)。 提供UTF-8、UTF-16、UTF-32之间的转换功能。
在文件 codepoint.hpp 第 126 行定义.
|
inlineconstexprnoexcept |
默认构造函数
构造空字符U+0000
在文件 codepoint.hpp 第 293 行定义.
被这些函数引用 append_to(), codepoint(), combine_surrogates(), decode_utf16(), decode_utf8(), from_utf32(), null() , 以及 replacement().
|
inlineexplicitconstexprnoexcept |
从uint32_t构造码点
| value | 原始码点值 |
如果值非法,自动替换为U+FFFD。
在文件 codepoint.hpp 第 302 行定义.
引用了 is_valid_codepoint(), REPLACEMENT_VALUE , 以及 value().
|
inlineexplicitconstexprnoexcept |
| void codepoint::append_to | ( | string & | result | ) | const |
追加UTF-8编码到string
| result | 目标字符串 |
将码点以UTF-8编码追加到string中。
被这些函数引用 u16character::to_string(), u32character::to_string(), u8character::to_string(), wcharacter::to_string(), character::to_u16string(), u16character::to_u16string(), u32character::to_u16string(), u8character::to_u16string(), wcharacter::to_u16string(), character::to_u32string(), u16character::to_u32string(), u8character::to_u32string(), wcharacter::to_u32string(), character::to_u8string(), u16character::to_u8string(), u32character::to_u8string(), wcharacter::to_u8string(), character::to_wstring(), u16character::to_wstring(), u32character::to_wstring() , 以及 u8character::to_wstring().
| void codepoint::append_to | ( | u16string & | result | ) | const |
追加UTF-16编码到u16string
| result | 目标UTF-16字符串 |
将码点以UTF-16编码追加到u16string中。 BMP字符追加单个码元,辅助平面字符追加代理对。
|
inline |
| void codepoint::append_to | ( | u8string & | result | ) | const |
追加UTF-8编码到u8string
| result | 目标UTF-8字符串 |
将码点以UTF-8编码追加到u8string中。
| void codepoint::append_to | ( | wstring & | result | ) | const |
|
inlinestaticconstexprnoexcept |
组合高代理项和低代理项为完整的Unicode码点
| high | 高代理项 |
| low | 低代理项 |
根据UTF-16编码规则将两个代理项组合为完整的码点。
在文件 codepoint.hpp 第 163 行定义.
引用了 codepoint().
|
inlinestaticnoexcept |
从UTF-16序列解码一个码点,并推进索引
| T | char16_t或wchar_t类型 |
| data | UTF-16数据指针 |
| index | 当前位置(解码后自动推进) |
| len | 数据总长度 |
| need_swap | 是否需要字节序反转 |
支持单码元和代理对解码,自动处理字节序转换。 无效序列返回替换符。
在文件 codepoint.hpp 第 226 行定义.
引用了 codepoint(), data() , 以及 replacement().
被这些函数引用 u16character::to_string(), wcharacter::to_string(), u16character::to_u16string(), u16character::to_u32string(), wcharacter::to_u32string(), u16character::to_u8string(), wcharacter::to_u8string() , 以及 u16character::to_wstring().
从UTF-8字节流解码一个码点,并推进索引
| data | UTF-8字节数据 |
| i | 当前位置(解码后自动推进) |
| len | 数据总长度 |
支持1-4字节的UTF-8序列,自动验证序列的有效性。 无效序列或截断序列返回替换符。
引用了 codepoint() , 以及 data().
被这些函数引用 u8character::to_string(), character::to_u16string(), u8character::to_u16string(), character::to_u32string(), u8character::to_u32string(), character::to_u8string(), character::to_wstring() , 以及 u8character::to_wstring().
|
inlinestaticconstexprnoexcept |
从UTF-32值直接构造码点
| value | UTF-32字符 |
UTF-32编码直接对应Unicode码点值。
在文件 codepoint.hpp 第 244 行定义.
引用了 codepoint() , 以及 value().
被这些函数引用 u32character::to_string(), u32character::to_u16string(), u32character::to_u8string() , 以及 u32character::to_wstring().
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
检查字符是否为高代理项
| c | UTF-16字符 |
高代理项的范围是0xD800-0xDBFF。
在文件 codepoint.hpp 第 140 行定义.
被这些函数引用 is_valid_codepoint().
|
inlinestaticconstexprnoexcept |
检查字符是否为低代理项
| c | UTF-16字符 |
低代理项的范围是0xDC00-0xDFFF。
在文件 codepoint.hpp 第 151 行定义.
被这些函数引用 is_valid_codepoint().
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
是否为辅助平面字符(需要UTF-16代理对)
在文件 codepoint.hpp 第 351 行定义.
引用了 MAX_VALUE.
被这些函数引用 needs_surrogate_pair() , 以及 utf16_length().
|
inlinestaticconstexprnoexcept |
检查码点值是否合法
| v | 要检查的码点值 |
合法条件:
在文件 codepoint.hpp 第 179 行定义.
引用了 is_high_surrogate(), is_low_surrogate() , 以及 MAX_VALUE.
被这些函数引用 codepoint().
|
inlineconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
构造替换符U+FFFD
用于表示无效或无法表示的Unicode字符。
在文件 codepoint.hpp 第 189 行定义.
引用了 codepoint() , 以及 REPLACEMENT_VALUE.
被这些函数引用 decode_utf16().
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
UTF-16编码后的码元数
BMP字符需要1个码元,辅助平面字符需要2个码元(代理对)。
在文件 codepoint.hpp 第 388 行定义.
引用了 is_supplementary().
|
inlineconstexprnoexcept |
UTF-8编码后的字节数
根据码点值计算所需UTF-8编码长度:
在文件 codepoint.hpp 第 369 行定义.
|
inlineconstexprnoexcept |
获取码点的uint32_t值
在文件 codepoint.hpp 第 321 行定义.
引用了 value().
被这些函数引用 codepoint(), codepoint(), from_utf32() , 以及 value().