Namespaces
Variants

std::text_encoding:: comp-name

From cppreference.net
static constexpr bool /*comp-name*/ ( std:: string_view a, std:: string_view b ) ;
(自 C++26 起)
( 仅用于说明* )

按照 Unicode 字符集别名匹配 规则,比较采用普通字面量编码的两个字符串 a b

两个字符串在满足以下条件时从左到右比较被视为相等:

  • 移除所有非字母数字字符,
  • 将所有字母转换为相同大小写,以及
  • 移除任何不紧跟在数字前缀后的独立 '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 否则。