std::text_encoding:: text_encoding
From cppreference.net
<
cpp
|
text
|
text encoding
|
constexpr
text_encoding
(
)
=
default
;
|
(1) | (自 C++26 起) |
|
constexpr
explicit
text_encoding
(
std::
string_view
enc
)
noexcept
;
|
(2) | (自 C++26 起) |
|
constexpr
text_encoding
(
std
::
text_encoding
::
id
i
)
noexcept
;
|
(3) | (自 C++26 起) |
构造一个新的文本编码对象。
若
enc
命名的
已注册字符编码
不是
NATS-DANO
或
NATS-DANO-ADD
,则构造的对象将具有对应的
MIBenum
值,否则其 MIBenum 将为
std
::
text_encoding
::
id
::
other
。
如果
enc.
size
(
)
>
std
::
text_encoding
::
max_name_length
||
enc.
contains
(
'
\0
'
)
,则行为未定义。
如果
i
是
std
::
text_encoding
::
id
::
other
或
std
::
text_encoding
::
id
::
unknown
,则构造的对象将具有空的
字符编码名称
,否则将具有
对应名称
之一。
参数
| enc | - | 字符编码名称 |
| i | - | MIBenum 值 |
示例
在 Compiler Explorer 上查看。
运行此代码
#include <text_encoding> int main() { constexpr std::text_encoding iso60 = std::text_encoding::ISO60DanishNorwegian; static_assert(iso60 == std::text_encoding("csISO60DanishNorwegian")); static_assert(iso60 == std::text_encoding("iso-ir-60")); static_assert(iso60 == std::text_encoding("NS_4551-1")); }
外部链接
| IANA字符集名称与MIBenum值注册表 。 |