命名空间
变体
操作

std::text_encoding::comp-name

来自 cppreference.cn
< cpp‎ | text‎ | text_encoding
static constexpr bool /*comp-name*/( std::string_view a, std::string_view b );
(C++26 起)
(仅作说明*)

比较两个普通字面量编码字符串 ab,遵循 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