unicode: add ASCII charset

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2025-06-05 12:00:17 +02:00
parent 862c073ca8
commit f454ae9cab

View File

@ -1,4 +1,4 @@
/*
/*
SPDX-License-Identifier: MIT
Copyright © 2023-2025 Amebis
*/
@ -31,6 +31,7 @@ namespace stdex
#ifdef _WIN32
system = CP_ACP,
oem = CP_OEMCP,
ascii = 20127,
utf7 = CP_UTF7,
utf8 = CP_UTF8,
utf16 = 1200 /*CP_WINUNICODE*/,
@ -40,6 +41,7 @@ namespace stdex
windows1252 = 1252,
#else
system = 0,
ascii,
utf7,
utf8,
utf16,
@ -80,6 +82,18 @@ namespace stdex
}
};
static const std::map<const char*, charset_id, charset_less> charsets = {
{ "ANSI_X3.4-1968", charset_id::ascii },
{ "ANSI_X3.4-1986", charset_id::ascii },
{ "ASCII", charset_id::ascii },
{ "CP367", charset_id::ascii },
{ "IBM367", charset_id::ascii },
{ "ISO-IR-6", charset_id::ascii },
{ "ISO646-US", charset_id::ascii },
{ "ISO_646.IRV:1991", charset_id::ascii },
{ "US", charset_id::ascii },
{ "US-ASCII", charset_id::ascii },
{ "CSASCII", charset_id::ascii },
{ "UNICODE-1-1-UTF-7", charset_id::utf7 },
{ "UTF-7", charset_id::utf7 },
{ "CSUNICODE11UTF7", charset_id::utf7 },
@ -458,6 +472,7 @@ namespace stdex
{
static const char* const encodings[static_cast<std::underlying_type_t<charset_id>>(charset_id::_max)] = {
"", // system
"ASCII", // ascii
"UTF-7", // utf7
"UTF-8", // utf8
#if BYTE_ORDER == BIG_ENDIAN