std::text_encoding::comp-name
來自 cppreference.com
< cpp | text | text_encoding
static constexpr bool /*comp-name*/( std::string_view a, std::string_view b ); |
(C++26 起) (僅作說明*) |
|
比較兩個普通字面量編碼字串 a 和 b,遵循 Unicode 字元集別名匹配規則。
兩個字串在以下處理後從左到右比較時被認為是相等的:
- 移除所有非字母數字字元,
- 將所有字母轉換為相同的大小寫,以及
- 移除任何不緊隨數字字首的獨立 '0' 字元序列。數字字首由非零數字('1' 到 '9')以及可選的一個或多個非字母數字字元組成。
以下是一些示例
static_assert(/*comp-name*/("UTF-8", "utf8") == true); static_assert(/*comp-name*/("u.t.f-008", "utf8") == true); static_assert(/*comp-name*/("ISO-8859-1", "iso88591") == true); static_assert(/*comp-name*/("ut8", "utf8") == false); static_assert(/*comp-name*/("utf-80", "utf8") == false);
[編輯] 引數
a, b | - | 要比較的字串 |
[編輯] 返回值
如果兩個字串按上述描述比較相等,則為 true;否則為 false。