| 1 | // -*- C++ -*- |
| 2 | //===----------------------------------------------------------------------===// |
| 3 | // |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_TEXT_ENCODING |
| 11 | #define _LIBCPP_TEXT_ENCODING |
| 12 | |
| 13 | /* text_encoding synopsis |
| 14 | namespace std { |
| 15 | |
| 16 | struct text_encoding; |
| 17 | |
| 18 | // [text.encoding.hash], hash support |
| 19 | template<class T> struct hash; |
| 20 | template<> struct hash<text_encoding>; |
| 21 | |
| 22 | struct text_encoding |
| 23 | { |
| 24 | static constexpr size_t max_name_length = 63; |
| 25 | |
| 26 | // [text.encoding.id], enumeration text_encoding::id |
| 27 | enum class id : int_least32_t { |
| 28 | see below |
| 29 | }; |
| 30 | using enum id; |
| 31 | |
| 32 | constexpr text_encoding() = default; |
| 33 | constexpr explicit text_encoding(string_view enc) noexcept; |
| 34 | constexpr text_encoding(id i) noexcept; |
| 35 | |
| 36 | constexpr id mib() const noexcept; |
| 37 | constexpr const char* name() const noexcept; |
| 38 | |
| 39 | // [text.encoding.aliases], class text_encoding::aliases_view |
| 40 | // struct aliases_view; |
| 41 | constexpr aliases_view aliases() const noexcept; |
| 42 | |
| 43 | friend constexpr bool operator==(const text_encoding& a, |
| 44 | const text_encoding& b) noexcept; |
| 45 | friend constexpr bool operator==(const text_encoding& encoding, id i) noexcept; |
| 46 | |
| 47 | static consteval text_encoding literal() noexcept; |
| 48 | static text_encoding environment(); |
| 49 | template<id i> static bool environment_is(); |
| 50 | |
| 51 | private: |
| 52 | id mib_ = id::unknown; // exposition only |
| 53 | char name_[max_name_length + 1] = {0}; // exposition only |
| 54 | static constexpr bool comp-name(string_view a, string_view b); // exposition only |
| 55 | }; |
| 56 | } |
| 57 | |
| 58 | */ |
| 59 | |
| 60 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 61 | # include <__cxx03/__config> |
| 62 | #else |
| 63 | # include <__config> |
| 64 | |
| 65 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 66 | # pragma GCC system_header |
| 67 | # endif |
| 68 | |
| 69 | # if _LIBCPP_STD_VER >= 26 |
| 70 | |
| 71 | # include <__algorithm/count.h> |
| 72 | # include <__algorithm/find_if.h> |
| 73 | # include <__algorithm/lower_bound.h> |
| 74 | # include <__cstddef/ptrdiff_t.h> |
| 75 | # include <__functional/hash.h> |
| 76 | # include <__iterator/iterator_traits.h> |
| 77 | # include <__ranges/enable_borrowed_range.h> |
| 78 | # include <__ranges/view_interface.h> |
| 79 | # include <climits> |
| 80 | # include <cstdint> |
| 81 | # include <string_view> |
| 82 | # include <version> |
| 83 | |
| 84 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 85 | struct text_encoding; |
| 86 | |
| 87 | _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS |
| 88 | |
| 89 | _LIBCPP_AVAILABILITY_TEXT_ENCODING_ENVIRONMENT _LIBCPP_EXPORTED_FROM_ABI text_encoding |
| 90 | __get_locale_encoding(const char* __name); |
| 91 | |
| 92 | _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS |
| 93 | |
| 94 | struct text_encoding { |
| 95 | static_assert(CHAR_BIT == 8, "libc++ only supports platforms where CHAR_BIT == 8" ); |
| 96 | enum class id : int_least32_t { |
| 97 | other = 1, |
| 98 | unknown = 2, |
| 99 | ASCII = 3, |
| 100 | ISOLatin1 = 4, |
| 101 | ISOLatin2 = 5, |
| 102 | ISOLatin3 = 6, |
| 103 | ISOLatin4 = 7, |
| 104 | ISOLatinCyrillic = 8, |
| 105 | ISOLatinArabic = 9, |
| 106 | ISOLatinGreek = 10, |
| 107 | ISOLatinHebrew = 11, |
| 108 | ISOLatin5 = 12, |
| 109 | ISOLatin6 = 13, |
| 110 | ISOTextComm = 14, |
| 111 | HalfWidthKatakana = 15, |
| 112 | JISEncoding = 16, |
| 113 | ShiftJIS = 17, |
| 114 | EUCPkdFmtJapanese = 18, |
| 115 | EUCFixWidJapanese = 19, |
| 116 | ISO4UnitedKingdom = 20, |
| 117 | ISO11SwedishForNames = 21, |
| 118 | ISO15Italian = 22, |
| 119 | ISO17Spanish = 23, |
| 120 | ISO21German = 24, |
| 121 | ISO60DanishNorwegian = 25, |
| 122 | ISO69French = 26, |
| 123 | ISO10646UTF1 = 27, |
| 124 | ISO646basic1983 = 28, |
| 125 | INVARIANT = 29, |
| 126 | ISO2IntlRefVersion = 30, |
| 127 | NATSSEFI = 31, |
| 128 | NATSSEFIADD = 32, // NATS-DANO (33) and NATS-DANO-ADD (34) are omitted by the standard. |
| 129 | ISO10Swedish = 35, |
| 130 | KSC56011987 = 36, |
| 131 | ISO2022KR = 37, |
| 132 | EUCKR = 38, |
| 133 | ISO2022JP = 39, |
| 134 | ISO2022JP2 = 40, |
| 135 | ISO13JISC6220jp = 41, |
| 136 | ISO14JISC6220ro = 42, |
| 137 | ISO16Portuguese = 43, |
| 138 | ISO18Greek7Old = 44, |
| 139 | ISO19LatinGreek = 45, |
| 140 | ISO25French = 46, |
| 141 | ISO27LatinGreek1 = 47, |
| 142 | ISO5427Cyrillic = 48, |
| 143 | ISO42JISC62261978 = 49, |
| 144 | ISO47BSViewdata = 50, |
| 145 | ISO49INIS = 51, |
| 146 | ISO50INIS8 = 52, |
| 147 | ISO51INISCyrillic = 53, |
| 148 | ISO54271981 = 54, |
| 149 | ISO5428Greek = 55, |
| 150 | ISO57GB1988 = 56, |
| 151 | ISO58GB231280 = 57, |
| 152 | ISO61Norwegian2 = 58, |
| 153 | ISO70VideotexSupp1 = 59, |
| 154 | ISO84Portuguese2 = 60, |
| 155 | ISO85Spanish2 = 61, |
| 156 | ISO86Hungarian = 62, |
| 157 | ISO87JISX0208 = 63, |
| 158 | ISO88Greek7 = 64, |
| 159 | ISO89ASMO449 = 65, |
| 160 | ISO90 = 66, |
| 161 | ISO91JISC62291984a = 67, |
| 162 | ISO92JISC62991984b = 68, |
| 163 | ISO93JIS62291984badd = 69, |
| 164 | ISO94JIS62291984hand = 70, |
| 165 | ISO95JIS62291984handadd = 71, |
| 166 | ISO96JISC62291984kana = 72, |
| 167 | ISO2033 = 73, |
| 168 | ISO99NAPLPS = 74, |
| 169 | ISO102T617bit = 75, |
| 170 | ISO103T618bit = 76, |
| 171 | ISO111ECMACyrillic = 77, |
| 172 | ISO121Canadian1 = 78, |
| 173 | ISO122Canadian2 = 79, |
| 174 | ISO123CSAZ24341985gr = 80, |
| 175 | ISO88596E = 81, |
| 176 | ISO88596I = 82, |
| 177 | ISO128T101G2 = 83, |
| 178 | ISO88598E = 84, |
| 179 | ISO88598I = 85, |
| 180 | ISO139CSN369103 = 86, |
| 181 | ISO141JUSIB1002 = 87, |
| 182 | ISO143IECP271 = 88, |
| 183 | ISO146Serbian = 89, |
| 184 | ISO147Macedonian = 90, |
| 185 | ISO150 = 91, |
| 186 | ISO151Cuba = 92, |
| 187 | ISO6937Add = 93, |
| 188 | ISO153GOST1976874 = 94, |
| 189 | ISO8859Supp = 95, |
| 190 | ISO10367Box = 96, |
| 191 | ISO158Lap = 97, |
| 192 | ISO159JISX02121990 = 98, |
| 193 | ISO646Danish = 99, |
| 194 | USDK = 100, |
| 195 | DKUS = 101, |
| 196 | KSC5636 = 102, |
| 197 | Unicode11UTF7 = 103, |
| 198 | ISO2022CN = 104, |
| 199 | ISO2022CNEXT = 105, |
| 200 | UTF8 = 106, |
| 201 | ISO885913 = 109, |
| 202 | ISO885914 = 110, |
| 203 | ISO885915 = 111, |
| 204 | ISO885916 = 112, |
| 205 | GBK = 113, |
| 206 | GB18030 = 114, |
| 207 | OSDEBCDICDF0415 = 115, |
| 208 | OSDEBCDICDF03IRV = 116, |
| 209 | OSDEBCDICDF041 = 117, |
| 210 | ISO115481 = 118, |
| 211 | KZ1048 = 119, |
| 212 | UCS2 = 1000, |
| 213 | UCS4 = 1001, |
| 214 | UnicodeASCII = 1002, |
| 215 | UnicodeLatin1 = 1003, |
| 216 | UnicodeJapanese = 1004, |
| 217 | UnicodeIBM1261 = 1005, |
| 218 | UnicodeIBM1268 = 1006, |
| 219 | UnicodeIBM1276 = 1007, |
| 220 | UnicodeIBM1264 = 1008, |
| 221 | UnicodeIBM1265 = 1009, |
| 222 | Unicode11 = 1010, |
| 223 | SCSU = 1011, |
| 224 | UTF7 = 1012, |
| 225 | UTF16BE = 1013, |
| 226 | UTF16LE = 1014, |
| 227 | UTF16 = 1015, |
| 228 | CESU8 = 1016, |
| 229 | UTF32 = 1017, |
| 230 | UTF32BE = 1018, |
| 231 | UTF32LE = 1019, |
| 232 | BOCU1 = 1020, |
| 233 | UTF7IMAP = 1021, |
| 234 | Windows30Latin1 = 2000, |
| 235 | Windows31Latin1 = 2001, |
| 236 | Windows31Latin2 = 2002, |
| 237 | Windows31Latin5 = 2003, |
| 238 | HPRoman8 = 2004, |
| 239 | AdobeStandardEncoding = 2005, |
| 240 | VenturaUS = 2006, |
| 241 | VenturaInternational = 2007, |
| 242 | DECMCS = 2008, |
| 243 | PC850Multilingual = 2009, |
| 244 | PC8DanishNorwegian = 2012, |
| 245 | PC862LatinHebrew = 2013, |
| 246 | PC8Turkish = 2014, |
| 247 | IBMSymbols = 2015, |
| 248 | IBMThai = 2016, |
| 249 | HPLegal = 2017, |
| 250 | HPPiFont = 2018, |
| 251 | HPMath8 = 2019, |
| 252 | HPPSMath = 2020, |
| 253 | HPDesktop = 2021, |
| 254 | VenturaMath = 2022, |
| 255 | MicrosoftPublishing = 2023, |
| 256 | Windows31J = 2024, |
| 257 | GB2312 = 2025, |
| 258 | Big5 = 2026, |
| 259 | Macintosh = 2027, |
| 260 | IBM037 = 2028, |
| 261 | IBM038 = 2029, |
| 262 | IBM273 = 2030, |
| 263 | IBM274 = 2031, |
| 264 | IBM275 = 2032, |
| 265 | IBM277 = 2033, |
| 266 | IBM278 = 2034, |
| 267 | IBM280 = 2035, |
| 268 | IBM281 = 2036, |
| 269 | IBM284 = 2037, |
| 270 | IBM285 = 2038, |
| 271 | IBM290 = 2039, |
| 272 | IBM297 = 2040, |
| 273 | IBM420 = 2041, |
| 274 | IBM423 = 2042, |
| 275 | IBM424 = 2043, |
| 276 | PC8CodePage437 = 2011, |
| 277 | IBM500 = 2044, |
| 278 | IBM851 = 2045, |
| 279 | PCp852 = 2010, |
| 280 | IBM855 = 2046, |
| 281 | IBM857 = 2047, |
| 282 | IBM860 = 2048, |
| 283 | IBM861 = 2049, |
| 284 | IBM863 = 2050, |
| 285 | IBM864 = 2051, |
| 286 | IBM865 = 2052, |
| 287 | IBM868 = 2053, |
| 288 | IBM869 = 2054, |
| 289 | IBM870 = 2055, |
| 290 | IBM871 = 2056, |
| 291 | IBM880 = 2057, |
| 292 | IBM891 = 2058, |
| 293 | IBM903 = 2059, |
| 294 | IBM904 = 2060, |
| 295 | IBM905 = 2061, |
| 296 | IBM918 = 2062, |
| 297 | IBM1026 = 2063, |
| 298 | IBMEBCDICATDE = 2064, |
| 299 | EBCDICATDEA = 2065, |
| 300 | EBCDICCAFR = 2066, |
| 301 | EBCDICDKNO = 2067, |
| 302 | EBCDICDKNOA = 2068, |
| 303 | EBCDICFISE = 2069, |
| 304 | EBCDICFISEA = 2070, |
| 305 | EBCDICFR = 2071, |
| 306 | EBCDICIT = 2072, |
| 307 | EBCDICPT = 2073, |
| 308 | EBCDICES = 2074, |
| 309 | EBCDICESA = 2075, |
| 310 | EBCDICESS = 2076, |
| 311 | EBCDICUK = 2077, |
| 312 | EBCDICUS = 2078, |
| 313 | Unknown8BiT = 2079, |
| 314 | Mnemonic = 2080, |
| 315 | Mnem = 2081, |
| 316 | VISCII = 2082, |
| 317 | VIQR = 2083, |
| 318 | KOI8R = 2084, |
| 319 | HZGB2312 = 2085, |
| 320 | IBM866 = 2086, |
| 321 | PC775Baltic = 2087, |
| 322 | KOI8U = 2088, |
| 323 | IBM00858 = 2089, |
| 324 | IBM00924 = 2090, |
| 325 | IBM01140 = 2091, |
| 326 | IBM01141 = 2092, |
| 327 | IBM01142 = 2093, |
| 328 | IBM01143 = 2094, |
| 329 | IBM01144 = 2095, |
| 330 | IBM01145 = 2096, |
| 331 | IBM01146 = 2097, |
| 332 | IBM01147 = 2098, |
| 333 | IBM01148 = 2099, |
| 334 | IBM01149 = 2100, |
| 335 | Big5HKSCS = 2101, |
| 336 | IBM1047 = 2102, |
| 337 | PTCP154 = 2103, |
| 338 | Amiga1251 = 2104, |
| 339 | KOI7switched = 2105, |
| 340 | BRF = 2106, |
| 341 | TSCII = 2107, |
| 342 | CP51932 = 2108, |
| 343 | windows874 = 2109, |
| 344 | windows1250 = 2250, |
| 345 | windows1251 = 2251, |
| 346 | windows1252 = 2252, |
| 347 | windows1253 = 2253, |
| 348 | windows1254 = 2254, |
| 349 | windows1255 = 2255, |
| 350 | windows1256 = 2256, |
| 351 | windows1257 = 2257, |
| 352 | windows1258 = 2258, |
| 353 | TIS620 = 2259, |
| 354 | CP50220 = 2260 |
| 355 | }; |
| 356 | |
| 357 | private: |
| 358 | static constexpr int __nats_dano_ = 33; |
| 359 | static constexpr int __nats_dano_add_ = 34; |
| 360 | |
| 361 | // A __te_data structure stores: |
| 362 | // Index into a table of offsets in the giant aliases string |
| 363 | // The MIB of that text encoding |
| 364 | // Number of aliases the current MIB holds |
| 365 | // We only need 6 bytes of information to store this information. |
| 366 | |
| 367 | // The data is structured in three different locations: |
| 368 | // The mib table (array of __te_data) |
| 369 | // Aliases string |
| 370 | // Table of offsets into the aliases string |
| 371 | |
| 372 | // All of the alias strings were transformed from an array of char* into one giant string split by '\0'. |
| 373 | // This allows us to reduce runtime memory footprint by not only removing the need to store ~884 pointers, it also |
| 374 | // significantly reduces the disk space taken by removing the need for relocation data for those pointers. |
| 375 | // We also know ahead of time that the total number of characters of all of these aliases combined can fit into 2 |
| 376 | // bytes, so we can also save even more memory by using 2 byte offsets rather than a full pointer into the aliases |
| 377 | // string. |
| 378 | |
| 379 | struct __te_data { |
| 380 | unsigned short __first_alias_index_; |
| 381 | unsigned short __mib_rep_; |
| 382 | unsigned char __num_aliases_; |
| 383 | |
| 384 | friend constexpr bool operator<(const __te_data& __enc, id __i) noexcept { |
| 385 | return __enc.__mib_rep_ < static_cast<unsigned short>(__i); |
| 386 | } |
| 387 | }; |
| 388 | |
| 389 | static constexpr bool __comp_name(string_view __a, string_view __b) noexcept { |
| 390 | if (__a.empty() || __b.empty()) { |
| 391 | return false; |
| 392 | } |
| 393 | |
| 394 | // Map any non-alphanumeric character to 255, skip prefix 0s, else get tolower(__n). |
| 395 | auto __map_char = [](char __n, bool& __in_number) -> unsigned char { |
| 396 | if (__n == '0') { |
| 397 | return __in_number ? '0' : 255; |
| 398 | } |
| 399 | __in_number = __n >= '1' && __n <= '9'; |
| 400 | |
| 401 | if ((__n >= '1' && __n <= '9') || (__n >= 'a' && __n <= 'z')) { |
| 402 | return __n; |
| 403 | } |
| 404 | if (__n >= 'A' && __n <= 'Z') { |
| 405 | return __n + ('a' - 'A'); // tolower |
| 406 | } |
| 407 | |
| 408 | return 255; |
| 409 | }; |
| 410 | |
| 411 | auto __a_ptr = __a.begin(), __b_ptr = __b.begin(); |
| 412 | bool __a_in_number = false, __b_in_number = false; |
| 413 | |
| 414 | unsigned char __a_val = 255, __b_val = 255; |
| 415 | for (;; __a_ptr++, __b_ptr++) { |
| 416 | while (__a_ptr != __a.end() && (__a_val = __map_char(*__a_ptr, __a_in_number)) == 255) |
| 417 | __a_ptr++; |
| 418 | while (__b_ptr != __b.end() && (__b_val = __map_char(*__b_ptr, __b_in_number)) == 255) |
| 419 | __b_ptr++; |
| 420 | |
| 421 | if (__a_ptr == __a.end()) |
| 422 | return __b_ptr == __b.end(); |
| 423 | if (__b_ptr == __b.end()) |
| 424 | return false; |
| 425 | if (__a_val != __b_val) |
| 426 | return false; |
| 427 | } |
| 428 | return true; |
| 429 | } |
| 430 | |
| 431 | static constexpr unsigned short __find_data_idx(string_view __a) noexcept { |
| 432 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__a.size() <= max_name_length, "input string_view must have size <= 63" ); |
| 433 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__a.contains('\0'), "input string_view must not contain '\\0'" ); |
| 434 | |
| 435 | auto __pred = [&__a](const __te_data& __entry) -> bool { |
| 436 | // Search aliases of text encoding for string |
| 437 | aliases_view __aliases(__entry); |
| 438 | return std::find_if(first: __aliases.begin(), last: __aliases.end(), pred: [&__a](auto __alias) { |
| 439 | return __comp_name(__a, b: __alias); |
| 440 | }) != __aliases.end(); |
| 441 | }; |
| 442 | |
| 443 | const __te_data* __found = std::find_if(first: __entries + 2, last: std::end(array: __entries), __pred); |
| 444 | if (__found == std::end(array: __entries)) { |
| 445 | return __other_idx_; // other |
| 446 | } |
| 447 | |
| 448 | return __found - __entries; |
| 449 | } |
| 450 | |
| 451 | static constexpr unsigned short __find_data_idx_by_id(id __i) noexcept { |
| 452 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__i >= id::other, "invalid text_encoding::id passed" ); |
| 453 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__i <= id::CP50220, "invalid text_encoding::id passed" ); |
| 454 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(int_least32_t(__i) != __nats_dano_, "Mib for NATS-DANO used" ); |
| 455 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(int_least32_t(__i) != __nats_dano_add_, "Mib for NATS-DANO-ADD used" ); |
| 456 | auto __found = std::lower_bound(first: std::begin(array: __entries), last: std::end(array: __entries), value: __i); |
| 457 | |
| 458 | if (__found == std::end(array: __entries)) { |
| 459 | return __unknown_idx_; // unknown |
| 460 | } |
| 461 | |
| 462 | return __found - __entries; |
| 463 | } |
| 464 | |
| 465 | public: |
| 466 | using enum id; |
| 467 | static constexpr size_t max_name_length = 63; |
| 468 | |
| 469 | // [text.encoding.aliases], class text_encoding::aliases_view |
| 470 | struct aliases_view : ranges::view_interface<aliases_view> { |
| 471 | struct __iterator { |
| 472 | using iterator_concept = random_access_iterator_tag; |
| 473 | using iterator_category = random_access_iterator_tag; |
| 474 | using value_type = const char*; |
| 475 | using reference = const char*; |
| 476 | using difference_type = int; |
| 477 | |
| 478 | constexpr __iterator() noexcept = default; |
| 479 | |
| 480 | [[nodiscard]] constexpr reference operator*() const noexcept { |
| 481 | return __get_alias_from_offset_table(idx: __current_idx_); |
| 482 | } |
| 483 | |
| 484 | [[nodiscard]] constexpr reference operator[](difference_type __n) const noexcept { |
| 485 | auto __it = *this; |
| 486 | return *(__it + __n); |
| 487 | } |
| 488 | |
| 489 | [[nodiscard]] friend constexpr __iterator operator+(__iterator __it, difference_type __n) noexcept { |
| 490 | __it += __n; |
| 491 | return __it; |
| 492 | } |
| 493 | |
| 494 | [[nodiscard]] friend constexpr __iterator operator+(difference_type __n, __iterator __it) noexcept { |
| 495 | __it += __n; |
| 496 | return __it; |
| 497 | } |
| 498 | |
| 499 | [[nodiscard]] friend constexpr __iterator operator-(__iterator __it, difference_type __n) noexcept { |
| 500 | __it -= __n; |
| 501 | return __it; |
| 502 | } |
| 503 | |
| 504 | [[nodiscard]] constexpr difference_type operator-(const __iterator& __other) const noexcept { |
| 505 | return __current_idx_ - __other.__current_idx_; |
| 506 | } |
| 507 | |
| 508 | constexpr __iterator& operator++() noexcept { |
| 509 | __current_idx_++; |
| 510 | return *this; |
| 511 | } |
| 512 | |
| 513 | constexpr __iterator operator++(int) noexcept { |
| 514 | auto __old = *this; |
| 515 | __current_idx_++; |
| 516 | return __old; |
| 517 | } |
| 518 | |
| 519 | constexpr __iterator& operator--() noexcept { |
| 520 | __current_idx_--; |
| 521 | return *this; |
| 522 | } |
| 523 | |
| 524 | constexpr __iterator operator--(int) noexcept { |
| 525 | auto __old = *this; |
| 526 | __current_idx_--; |
| 527 | return __old; |
| 528 | } |
| 529 | |
| 530 | constexpr __iterator& operator+=(difference_type __n) noexcept { |
| 531 | __current_idx_ += __n; |
| 532 | return *this; |
| 533 | } |
| 534 | |
| 535 | constexpr __iterator& operator-=(difference_type __n) noexcept { return (*this += -__n); } |
| 536 | |
| 537 | friend constexpr auto operator<=>(const __iterator& __it, const __iterator& __it2) noexcept = default; |
| 538 | |
| 539 | private: |
| 540 | friend struct aliases_view; |
| 541 | |
| 542 | constexpr __iterator(unsigned short __enc_d) noexcept : __current_idx_(__enc_d) {} |
| 543 | |
| 544 | unsigned short __current_idx_; |
| 545 | }; // __iterator |
| 546 | |
| 547 | [[nodiscard]] constexpr __iterator begin() const noexcept { return __iterator(__first_idx_); } |
| 548 | |
| 549 | [[nodiscard]] constexpr __iterator end() const noexcept { return __iterator(__last_idx_); } |
| 550 | |
| 551 | private: |
| 552 | friend struct text_encoding; |
| 553 | |
| 554 | constexpr aliases_view(const __te_data& __d) |
| 555 | : __first_idx_(__d.__first_alias_index_), __last_idx_(__d.__first_alias_index_ + __d.__num_aliases_) {} |
| 556 | |
| 557 | unsigned short __first_idx_; |
| 558 | unsigned short __last_idx_; |
| 559 | }; // aliases_view |
| 560 | |
| 561 | constexpr text_encoding() = default; |
| 562 | |
| 563 | constexpr explicit text_encoding(string_view __enc) noexcept : __encoding_idx_(__find_data_idx(a: __enc)) { |
| 564 | __enc.copy(s: __name_, n: max_name_length, pos: 0); |
| 565 | } |
| 566 | |
| 567 | constexpr text_encoding(id __i) noexcept : __encoding_idx_(__find_data_idx_by_id(__i)) { |
| 568 | const char* __alias = __get_alias_from_offset_table(idx: __get().__first_alias_index_); |
| 569 | if (__alias[0] != '\0') { |
| 570 | string_view(__alias).copy(s: __name_, n: max_name_length); |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | [[nodiscard]] constexpr id mib() const noexcept { return id(__get().__mib_rep_); } |
| 575 | |
| 576 | [[nodiscard]] constexpr const char* name() const noexcept { return __name_; } |
| 577 | |
| 578 | [[nodiscard]] constexpr aliases_view aliases() const noexcept { return aliases_view(__get()); } |
| 579 | |
| 580 | friend constexpr bool operator==(const text_encoding& __a, const text_encoding& __b) noexcept { |
| 581 | return __a.mib() == id::other && __b.mib() == id::other |
| 582 | ? __comp_name(a: __a.__name_, b: __b.__name_) |
| 583 | : __a.mib() == __b.mib(); |
| 584 | } |
| 585 | |
| 586 | friend constexpr bool operator==(const text_encoding& __encoding, id __i) noexcept { return __encoding.mib() == __i; } |
| 587 | |
| 588 | [[nodiscard]] static consteval text_encoding literal() noexcept { |
| 589 | // TODO: Remove this branch once we have __GNUC_EXECUTION_CHARSET_NAME or __clang_literal_encoding__ unconditionally |
| 590 | # ifdef __GNUC_EXECUTION_CHARSET_NAME |
| 591 | return text_encoding(__GNUC_EXECUTION_CHARSET_NAME); |
| 592 | # elif defined(__clang_literal_encoding__) |
| 593 | return text_encoding(__clang_literal_encoding__); |
| 594 | # else |
| 595 | return text_encoding(); |
| 596 | # endif |
| 597 | } |
| 598 | |
| 599 | # if _LIBCPP_HAS_LOCALIZATION |
| 600 | [[nodiscard]] _LIBCPP_AVAILABILITY_TEXT_ENCODING_ENVIRONMENT static text_encoding environment() { |
| 601 | # if defined(_LIBCPP_WIN32API) |
| 602 | return __get_locale_encoding(nullptr); |
| 603 | # else |
| 604 | return __get_locale_encoding(name: "" ); |
| 605 | # endif |
| 606 | } |
| 607 | |
| 608 | template <id _Id> |
| 609 | [[nodiscard]] _LIBCPP_AVAILABILITY_TEXT_ENCODING_ENVIRONMENT static bool environment_is() { |
| 610 | // TODO: It may be worthwhile to implement an optimization for popular encodings, e.g. UTF-8, |
| 611 | // to allow checking the environment text encoding without needing to use the data tables. |
| 612 | |
| 613 | # if defined(__ANDROID__) |
| 614 | return _Id == std::text_encoding::id::UTF8; |
| 615 | # else |
| 616 | return environment() == _Id; |
| 617 | # endif |
| 618 | } |
| 619 | # else |
| 620 | static text_encoding environment() = delete; |
| 621 | |
| 622 | template <id> |
| 623 | static bool environment_is() = delete; |
| 624 | # endif |
| 625 | |
| 626 | private: |
| 627 | constexpr const __te_data& __get() const { return __entries[__encoding_idx_]; } |
| 628 | |
| 629 | static constexpr char const* __get_alias_from_offset_table(unsigned short __idx) { |
| 630 | return __aliases_string + __alias_offsets.__table[__idx]; |
| 631 | } |
| 632 | |
| 633 | static constexpr auto __other_idx_ = 0u; |
| 634 | static constexpr auto __unknown_idx_ = 1u; |
| 635 | |
| 636 | char __name_[max_name_length + 1]{}; |
| 637 | unsigned short __encoding_idx_{1u}; |
| 638 | |
| 639 | static constexpr __te_data __entries[] = { |
| 640 | {0, 1, 0}, {1, 2, 0}, {2, 3, 11}, {13, 4, 9}, {22, 5, 7}, {29, 6, 7}, {36, 7, 7}, |
| 641 | {43, 8, 6}, {49, 9, 8}, {57, 10, 9}, {66, 11, 6}, {72, 12, 7}, {79, 13, 6}, {85, 14, 3}, |
| 642 | {88, 15, 3}, {91, 16, 2}, {93, 17, 3}, {96, 18, 3}, {99, 19, 2}, {101, 20, 6}, {107, 21, 5}, |
| 643 | {112, 22, 4}, {116, 23, 4}, {120, 24, 5}, {125, 25, 6}, {131, 26, 5}, {136, 27, 2}, {138, 28, 3}, |
| 644 | {141, 29, 2}, {143, 30, 4}, {147, 31, 3}, {150, 32, 3}, {153, 35, 7}, {160, 36, 6}, {166, 37, 2}, |
| 645 | {168, 38, 2}, {170, 39, 2}, {172, 40, 2}, {174, 41, 6}, {180, 42, 5}, {185, 43, 4}, {189, 44, 3}, |
| 646 | {192, 45, 3}, {195, 46, 4}, {199, 47, 3}, {202, 48, 3}, {205, 49, 3}, {208, 50, 3}, {211, 51, 3}, |
| 647 | {214, 52, 3}, {217, 53, 3}, {220, 54, 4}, {224, 55, 3}, {227, 56, 5}, {232, 57, 4}, {236, 58, 5}, |
| 648 | {241, 59, 3}, {244, 60, 4}, {248, 61, 4}, {252, 62, 5}, {257, 63, 5}, {262, 64, 3}, {265, 65, 5}, |
| 649 | {270, 66, 2}, {272, 67, 4}, {276, 68, 5}, {281, 69, 4}, {285, 70, 4}, {289, 71, 4}, {293, 72, 3}, |
| 650 | {296, 73, 4}, {300, 74, 5}, {305, 75, 3}, {308, 76, 4}, {312, 77, 4}, {316, 78, 7}, {323, 79, 6}, |
| 651 | {329, 80, 3}, {332, 81, 3}, {335, 82, 3}, {338, 83, 3}, {341, 84, 3}, {344, 85, 3}, {347, 86, 3}, |
| 652 | {350, 87, 6}, {356, 88, 3}, {359, 89, 4}, {363, 90, 4}, {367, 91, 4}, {371, 92, 5}, {376, 93, 3}, |
| 653 | {379, 94, 4}, {383, 95, 4}, {387, 96, 3}, {390, 97, 4}, {394, 98, 4}, {398, 99, 5}, {403, 100, 2}, |
| 654 | {405, 101, 2}, {407, 102, 3}, {410, 103, 2}, {412, 104, 2}, {414, 105, 2}, {416, 106, 2}, {418, 109, 2}, |
| 655 | {420, 110, 8}, {428, 111, 4}, {432, 112, 7}, {439, 113, 5}, {444, 114, 2}, {446, 115, 2}, {448, 116, 2}, |
| 656 | {450, 117, 2}, {452, 118, 4}, {456, 119, 4}, {460, 1000, 2}, {462, 1001, 2}, {464, 1002, 2}, {466, 1003, 3}, |
| 657 | {469, 1004, 2}, {471, 1005, 2}, {473, 1006, 2}, {475, 1007, 2}, {477, 1008, 2}, {479, 1009, 2}, {481, 1010, 2}, |
| 658 | {483, 1011, 2}, {485, 1012, 2}, {487, 1013, 2}, {489, 1014, 2}, {491, 1015, 2}, {493, 1016, 3}, {496, 1017, 2}, |
| 659 | {498, 1018, 2}, {500, 1019, 2}, {502, 1020, 3}, {505, 1021, 2}, {507, 2000, 2}, {509, 2001, 2}, {511, 2002, 2}, |
| 660 | {513, 2003, 2}, {515, 2004, 4}, {519, 2005, 2}, {521, 2006, 2}, {523, 2007, 2}, {525, 2008, 3}, {528, 2009, 4}, |
| 661 | {532, 2010, 4}, {536, 2011, 4}, {540, 2012, 2}, {542, 2013, 4}, {546, 2014, 2}, {548, 2015, 2}, {550, 2016, 2}, |
| 662 | {552, 2017, 2}, {554, 2018, 2}, {556, 2019, 2}, {558, 2020, 2}, {560, 2021, 2}, {562, 2022, 2}, {564, 2023, 2}, |
| 663 | {566, 2024, 2}, {568, 2025, 2}, {570, 2026, 2}, {572, 2027, 3}, {575, 2028, 7}, {582, 2029, 4}, {586, 2030, 3}, |
| 664 | {589, 2031, 4}, {593, 2032, 4}, {597, 2033, 4}, {601, 2034, 5}, {606, 2035, 4}, {610, 2036, 4}, {614, 2037, 4}, |
| 665 | {618, 2038, 4}, {622, 2039, 4}, {626, 2040, 4}, {630, 2041, 4}, {634, 2042, 4}, {638, 2043, 4}, {642, 2044, 5}, |
| 666 | {647, 2045, 4}, {651, 2046, 4}, {655, 2047, 4}, {659, 2048, 4}, {663, 2049, 5}, {668, 2050, 4}, {672, 2051, 3}, |
| 667 | {675, 2052, 4}, {679, 2053, 4}, {683, 2054, 5}, {688, 2055, 5}, {693, 2056, 4}, {697, 2057, 4}, {701, 2058, 3}, |
| 668 | {704, 2059, 3}, {707, 2060, 4}, {711, 2061, 4}, {715, 2062, 4}, {719, 2063, 3}, {722, 2064, 2}, {724, 2065, 2}, |
| 669 | {726, 2066, 2}, {728, 2067, 2}, {730, 2068, 2}, {732, 2069, 2}, {734, 2070, 2}, {736, 2071, 2}, {738, 2072, 2}, |
| 670 | {740, 2073, 2}, {742, 2074, 2}, {744, 2075, 2}, {746, 2076, 2}, {748, 2077, 2}, {750, 2078, 2}, {752, 2079, 2}, |
| 671 | {754, 2080, 2}, {756, 2081, 2}, {758, 2082, 2}, {760, 2083, 2}, {762, 2084, 2}, {764, 2085, 1}, {765, 2086, 4}, |
| 672 | {769, 2087, 3}, {772, 2088, 2}, {774, 2089, 5}, {779, 2090, 5}, {784, 2091, 5}, {789, 2092, 5}, {794, 2093, 6}, |
| 673 | {800, 2094, 6}, {806, 2095, 5}, {811, 2096, 5}, {816, 2097, 5}, {821, 2098, 5}, {826, 2099, 5}, {831, 2100, 5}, |
| 674 | {836, 2101, 2}, {838, 2102, 3}, {841, 2103, 5}, {846, 2104, 5}, {851, 2105, 2}, {853, 2106, 2}, {855, 2107, 2}, |
| 675 | {857, 2108, 2}, {859, 2109, 2}, {861, 2250, 2}, {863, 2251, 2}, {865, 2252, 2}, {867, 2253, 2}, {869, 2254, 2}, |
| 676 | {871, 2255, 2}, {873, 2256, 2}, {875, 2257, 2}, {877, 2258, 2}, {879, 2259, 3}, {882, 2260, 2}}; |
| 677 | |
| 678 | static constexpr char __aliases_string[] = |
| 679 | "US-ASCII\0iso-ir-6\0ANSI_X3.4-1968\0ANSI_X3.4-1986\0ISO_646.irv:1991\0ISO646-" |
| 680 | "US\0us\0IBM367\0cp367\0csASCII\0ASCII\0ISO_8859-1:1987\0iso-ir-100\0ISO_8859-1\0ISO-8859-" |
| 681 | "1\0latin1\0l1\0IBM819\0CP819\0csISOLatin1\0ISO_8859-2:1987\0iso-ir-101\0ISO_8859-2\0ISO-8859-" |
| 682 | "2\0latin2\0l2\0csISOLatin2\0ISO_8859-3:1988\0iso-ir-109\0ISO_8859-3\0ISO-8859-3\0latin3\0l3\0csISOLatin3\0ISO_" |
| 683 | "8859-4:1988\0iso-ir-110\0ISO_8859-4\0ISO-8859-4\0latin4\0l4\0csISOLatin4\0ISO_8859-5:1988\0iso-ir-144\0ISO_8859-" |
| 684 | "5\0ISO-8859-5\0cyrillic\0csISOLatinCyrillic\0ISO_8859-6:1987\0iso-ir-127\0ISO_8859-6\0ISO-8859-6\0ECMA-" |
| 685 | "114\0ASMO-708\0arabic\0csISOLatinArabic\0ISO_8859-7:1987\0iso-ir-126\0ISO_8859-7\0ISO-8859-7\0ELOT_928\0ECMA-" |
| 686 | "118\0greek\0greek8\0csISOLatinGreek\0ISO_8859-8:1988\0iso-ir-138\0ISO_8859-8\0ISO-8859-" |
| 687 | "8\0hebrew\0csISOLatinHebrew\0ISO_8859-9:1989\0iso-ir-148\0ISO_8859-9\0ISO-8859-9\0latin5\0l5\0csISOLatin5\0ISO-" |
| 688 | "8859-10\0iso-ir-157\0l6\0ISO_8859-10:1992\0csISOLatin6\0latin6\0ISO_6937-2-add\0iso-ir-142\0csISOTextComm\0JIS_" |
| 689 | "X0201\0X0201\0csHalfWidthKatakana\0JIS_Encoding\0csJISEncoding\0Shift_JIS\0MS_Kanji\0csShiftJIS\0Extended_UNIX_" |
| 690 | "Code_Packed_Format_for_Japanese\0csEUCPkdFmtJapanese\0EUC-JP\0Extended_UNIX_Code_Fixed_Width_for_" |
| 691 | "Japanese\0csEUCFixWidJapanese\0BS_4730\0iso-ir-4\0ISO646-GB\0gb\0uk\0csISO4UnitedKingdom\0SEN_850200_C\0iso-ir-" |
| 692 | "11\0ISO646-SE2\0se2\0csISO11SwedishForNames\0IT\0iso-ir-15\0ISO646-IT\0csISO15Italian\0ES\0iso-ir-17\0ISO646-" |
| 693 | "ES\0csISO17Spanish\0DIN_66003\0iso-ir-21\0de\0ISO646-DE\0csISO21German\0NS_4551-1\0iso-ir-60\0ISO646-" |
| 694 | "NO\0no\0csISO60DanishNorwegian\0csISO60Norwegian1\0NF_Z_62-010\0iso-ir-69\0ISO646-FR\0fr\0csISO69French\0ISO-" |
| 695 | "10646-UTF-1\0csISO10646UTF1\0ISO_646.basic:1983\0ref\0csISO646basic1983\0INVARIANT\0csINVARIANT\0ISO_646.irv:" |
| 696 | "1983\0iso-ir-2\0irv\0csISO2IntlRefVersion\0NATS-SEFI\0iso-ir-8-1\0csNATSSEFI\0NATS-SEFI-ADD\0iso-ir-8-" |
| 697 | "2\0csNATSSEFIADD\0SEN_850200_B\0iso-ir-10\0FI\0ISO646-FI\0ISO646-SE\0se\0csISO10Swedish\0KS_C_5601-1987\0iso-ir-" |
| 698 | "149\0KS_C_5601-1989\0KSC_5601\0korean\0csKSC56011987\0ISO-2022-KR\0csISO2022KR\0EUC-KR\0csEUCKR\0ISO-2022-" |
| 699 | "JP\0csISO2022JP\0ISO-2022-JP-2\0csISO2022JP2\0JIS_C6220-1969-jp\0JIS_C6220-1969\0iso-ir-13\0katakana\0x0201-" |
| 700 | "7\0csISO13JISC6220jp\0JIS_C6220-1969-ro\0iso-ir-14\0jp\0ISO646-JP\0csISO14JISC6220ro\0PT\0iso-ir-16\0ISO646-" |
| 701 | "PT\0csISO16Portuguese\0greek7-old\0iso-ir-18\0csISO18Greek7Old\0latin-greek\0iso-ir-19\0csISO19LatinGreek\0NF_Z_" |
| 702 | "62-010_(1973)\0iso-ir-25\0ISO646-FR1\0csISO25French\0Latin-greek-1\0iso-ir-27\0csISO27LatinGreek1\0ISO_" |
| 703 | "5427\0iso-ir-37\0csISO5427Cyrillic\0JIS_C6226-1978\0iso-ir-42\0csISO42JISC62261978\0BS_viewdata\0iso-ir-" |
| 704 | "47\0csISO47BSViewdata\0INIS\0iso-ir-49\0csISO49INIS\0INIS-8\0iso-ir-50\0csISO50INIS8\0INIS-cyrillic\0iso-ir-" |
| 705 | "51\0csISO51INISCyrillic\0ISO_5427:1981\0iso-ir-54\0ISO5427Cyrillic1981\0csISO54271981\0ISO_5428:1980\0iso-ir-" |
| 706 | "55\0csISO5428Greek\0GB_1988-80\0iso-ir-57\0cn\0ISO646-CN\0csISO57GB1988\0GB_2312-80\0iso-ir-" |
| 707 | "58\0chinese\0csISO58GB231280\0NS_4551-2\0ISO646-NO2\0iso-ir-61\0no2\0csISO61Norwegian2\0videotex-suppl\0iso-ir-" |
| 708 | "70\0csISO70VideotexSupp1\0PT2\0iso-ir-84\0ISO646-PT2\0csISO84Portuguese2\0ES2\0iso-ir-85\0ISO646-" |
| 709 | "ES2\0csISO85Spanish2\0MSZ_7795.3\0iso-ir-86\0ISO646-HU\0hu\0csISO86Hungarian\0JIS_C6226-1983\0iso-ir-" |
| 710 | "87\0x0208\0JIS_X0208-1983\0csISO87JISX0208\0greek7\0iso-ir-88\0csISO88Greek7\0ASMO_449\0ISO_9036\0arabic7\0iso-" |
| 711 | "ir-89\0csISO89ASMO449\0iso-ir-90\0csISO90\0JIS_C6229-1984-a\0iso-ir-91\0jp-ocr-a\0csISO91JISC62291984a\0JIS_" |
| 712 | "C6229-1984-b\0iso-ir-92\0ISO646-JP-OCR-B\0jp-ocr-b\0csISO92JISC62991984b\0JIS_C6229-1984-b-add\0iso-ir-93\0jp-" |
| 713 | "ocr-b-add\0csISO93JIS62291984badd\0JIS_C6229-1984-hand\0iso-ir-94\0jp-ocr-hand\0csISO94JIS62291984hand\0JIS_" |
| 714 | "C6229-1984-hand-add\0iso-ir-95\0jp-ocr-hand-add\0csISO95JIS62291984handadd\0JIS_C6229-1984-kana\0iso-ir-" |
| 715 | "96\0csISO96JISC62291984kana\0ISO_2033-1983\0iso-ir-98\0e13b\0csISO2033\0ANSI_X3.110-1983\0iso-ir-99\0CSA_T500-" |
| 716 | "1983\0NAPLPS\0csISO99NAPLPS\0T.61-7bit\0iso-ir-102\0csISO102T617bit\0T.61-8bit\0T.61\0iso-ir-" |
| 717 | "103\0csISO103T618bit\0ECMA-cyrillic\0iso-ir-111\0KOI8-E\0csISO111ECMACyrillic\0CSA_Z243.4-1985-1\0iso-ir-" |
| 718 | "121\0ISO646-CA\0csa7-1\0csa71\0ca\0csISO121Canadian1\0CSA_Z243.4-1985-2\0iso-ir-122\0ISO646-CA2\0csa7-" |
| 719 | "2\0csa72\0csISO122Canadian2\0CSA_Z243.4-1985-gr\0iso-ir-123\0csISO123CSAZ24341985gr\0ISO_8859-6-" |
| 720 | "E\0csISO88596E\0ISO-8859-6-E\0ISO_8859-6-I\0csISO88596I\0ISO-8859-6-I\0T.101-G2\0iso-ir-" |
| 721 | "128\0csISO128T101G2\0ISO_8859-8-E\0csISO88598E\0ISO-8859-8-E\0ISO_8859-8-I\0csISO88598I\0ISO-8859-8-I\0CSN_" |
| 722 | "369103\0iso-ir-139\0csISO139CSN369103\0JUS_I.B1.002\0iso-ir-141\0ISO646-YU\0js\0yu\0csISO141JUSIB1002\0IEC_P27-" |
| 723 | "1\0iso-ir-143\0csISO143IECP271\0JUS_I.B1.003-serb\0iso-ir-146\0serbian\0csISO146Serbian\0JUS_I.B1.003-" |
| 724 | "mac\0macedonian\0iso-ir-147\0csISO147Macedonian\0greek-ccitt\0iso-ir-150\0csISO150\0csISO150GreekCCITT\0NC_NC00-" |
| 725 | "10:81\0cuba\0iso-ir-151\0ISO646-CU\0csISO151Cuba\0ISO_6937-2-25\0iso-ir-152\0csISO6937Add\0GOST_19768-74\0ST_" |
| 726 | "SEV_358-88\0iso-ir-153\0csISO153GOST1976874\0ISO_8859-supp\0iso-ir-154\0latin1-2-5\0csISO8859Supp\0ISO_10367-" |
| 727 | "box\0iso-ir-155\0csISO10367Box\0latin-lap\0lap\0iso-ir-158\0csISO158Lap\0JIS_X0212-1990\0x0212\0iso-ir-" |
| 728 | "159\0csISO159JISX02121990\0DS_2089\0DS2089\0ISO646-DK\0dk\0csISO646Danish\0us-dk\0csUSDK\0dk-" |
| 729 | "us\0csDKUS\0KSC5636\0ISO646-KR\0csKSC5636\0UNICODE-1-1-UTF-7\0csUnicode11UTF7\0ISO-2022-CN\0csISO2022CN\0ISO-" |
| 730 | "2022-CN-EXT\0csISO2022CNEXT\0UTF-8\0csUTF8\0ISO-8859-13\0csISO885913\0ISO-8859-14\0iso-ir-199\0ISO_8859-14:" |
| 731 | "1998\0ISO_8859-14\0latin8\0iso-celtic\0l8\0csISO885914\0ISO-8859-15\0ISO_8859-15\0Latin-9\0csISO885915\0ISO-" |
| 732 | "8859-16\0iso-ir-226\0ISO_8859-16:2001\0ISO_8859-16\0latin10\0l10\0csISO885916\0GBK\0CP936\0MS936\0windows-" |
| 733 | "936\0csGBK\0GB18030\0csGB18030\0OSD_EBCDIC_DF04_15\0csOSDEBCDICDF0415\0OSD_EBCDIC_DF03_" |
| 734 | "IRV\0csOSDEBCDICDF03IRV\0OSD_EBCDIC_DF04_1\0csOSDEBCDICDF041\0ISO-11548-1\0ISO_11548-1\0ISO_TR_11548-" |
| 735 | "1\0csISO115481\0KZ-1048\0STRK1048-2002\0RK1048\0csKZ1048\0ISO-10646-UCS-2\0csUnicode\0ISO-10646-UCS-" |
| 736 | "4\0csUCS4\0ISO-10646-UCS-Basic\0csUnicodeASCII\0ISO-10646-Unicode-Latin1\0csUnicodeLatin1\0ISO-10646\0ISO-10646-" |
| 737 | "J-1\0csUnicodeJapanese\0ISO-Unicode-IBM-1261\0csUnicodeIBM1261\0ISO-Unicode-IBM-1268\0csUnicodeIBM1268\0ISO-" |
| 738 | "Unicode-IBM-1276\0csUnicodeIBM1276\0ISO-Unicode-IBM-1264\0csUnicodeIBM1264\0ISO-Unicode-IBM-" |
| 739 | "1265\0csUnicodeIBM1265\0UNICODE-1-1\0csUnicode11\0SCSU\0csSCSU\0UTF-7\0csUTF7\0UTF-16BE\0csUTF16BE\0UTF-" |
| 740 | "16LE\0csUTF16LE\0UTF-16\0csUTF16\0CESU-8\0csCESU8\0csCESU-8\0UTF-32\0csUTF32\0UTF-32BE\0csUTF32BE\0UTF-" |
| 741 | "32LE\0csUTF32LE\0BOCU-1\0csBOCU1\0csBOCU-1\0UTF-7-IMAP\0csUTF7IMAP\0ISO-8859-1-Windows-3.0-Latin-" |
| 742 | "1\0csWindows30Latin1\0ISO-8859-1-Windows-3.1-Latin-1\0csWindows31Latin1\0ISO-8859-2-Windows-Latin-" |
| 743 | "2\0csWindows31Latin2\0ISO-8859-9-Windows-Latin-5\0csWindows31Latin5\0hp-roman8\0roman8\0r8\0csHPRoman8\0Adobe-" |
| 744 | "Standard-Encoding\0csAdobeStandardEncoding\0Ventura-US\0csVenturaUS\0Ventura-" |
| 745 | "International\0csVenturaInternational\0DEC-" |
| 746 | "MCS\0dec\0csDECMCS\0IBM850\0cp850\0850\0csPC850Multilingual\0IBM852\0cp852\0852\0csPCp852\0IBM437\0cp437\0" |
| 747 | "437\0csPC8CodePage437\0PC8-Danish-Norwegian\0csPC8DanishNorwegian\0IBM862\0cp862\0862\0csPC862LatinHebrew\0PC8-" |
| 748 | "Turkish\0csPC8Turkish\0IBM-Symbols\0csIBMSymbols\0IBM-Thai\0csIBMThai\0HP-Legal\0csHPLegal\0HP-Pi-" |
| 749 | "font\0csHPPiFont\0HP-Math8\0csHPMath8\0Adobe-Symbol-Encoding\0csHPPSMath\0HP-DeskTop\0csHPDesktop\0Ventura-" |
| 750 | "Math\0csVenturaMath\0Microsoft-Publishing\0csMicrosoftPublishing\0Windows-" |
| 751 | "31J\0csWindows31J\0GB2312\0csGB2312\0Big5\0csBig5\0macintosh\0mac\0csMacintosh\0IBM037\0cp037\0ebcdic-cp-" |
| 752 | "us\0ebcdic-cp-ca\0ebcdic-cp-wt\0ebcdic-cp-nl\0csIBM037\0IBM038\0EBCDIC-" |
| 753 | "INT\0cp038\0csIBM038\0IBM273\0CP273\0csIBM273\0IBM274\0EBCDIC-BE\0CP274\0csIBM274\0IBM275\0EBCDIC-" |
| 754 | "BR\0cp275\0csIBM275\0IBM277\0EBCDIC-CP-DK\0EBCDIC-CP-NO\0csIBM277\0IBM278\0CP278\0ebcdic-cp-fi\0ebcdic-cp-" |
| 755 | "se\0csIBM278\0IBM280\0CP280\0ebcdic-cp-it\0csIBM280\0IBM281\0EBCDIC-JP-" |
| 756 | "E\0cp281\0csIBM281\0IBM284\0CP284\0ebcdic-cp-es\0csIBM284\0IBM285\0CP285\0ebcdic-cp-" |
| 757 | "gb\0csIBM285\0IBM290\0cp290\0EBCDIC-JP-kana\0csIBM290\0IBM297\0cp297\0ebcdic-cp-" |
| 758 | "fr\0csIBM297\0IBM420\0cp420\0ebcdic-cp-ar1\0csIBM420\0IBM423\0cp423\0ebcdic-cp-" |
| 759 | "gr\0csIBM423\0IBM424\0cp424\0ebcdic-cp-he\0csIBM424\0IBM500\0CP500\0ebcdic-cp-be\0ebcdic-cp-" |
| 760 | "ch\0csIBM500\0IBM851\0cp851\0851\0csIBM851\0IBM855\0cp855\0855\0csIBM855\0IBM857\0cp857\0857\0csIBM857\0IBM860\0" |
| 761 | "cp860\0860\0csIBM860\0IBM861\0cp861\0861\0cp-" |
| 762 | "is\0csIBM861\0IBM863\0cp863\0863\0csIBM863\0IBM864\0cp864\0csIBM864\0IBM865\0cp865\0865\0csIBM865\0IBM868\0CP868" |
| 763 | "\0cp-ar\0csIBM868\0IBM869\0cp869\0869\0cp-gr\0csIBM869\0IBM870\0CP870\0ebcdic-cp-roece\0ebcdic-cp-" |
| 764 | "yu\0csIBM870\0IBM871\0CP871\0ebcdic-cp-is\0csIBM871\0IBM880\0cp880\0EBCDIC-" |
| 765 | "Cyrillic\0csIBM880\0IBM891\0cp891\0csIBM891\0IBM903\0cp903\0csIBM903\0IBM904\0cp904\0904\0csIBBM904\0IBM905\0CP9" |
| 766 | "05\0ebcdic-cp-tr\0csIBM905\0IBM918\0CP918\0ebcdic-cp-ar2\0csIBM918\0IBM1026\0CP1026\0csIBM1026\0EBCDIC-AT-" |
| 767 | "DE\0csIBMEBCDICATDE\0EBCDIC-AT-DE-A\0csEBCDICATDEA\0EBCDIC-CA-FR\0csEBCDICCAFR\0EBCDIC-DK-" |
| 768 | "NO\0csEBCDICDKNO\0EBCDIC-DK-NO-A\0csEBCDICDKNOA\0EBCDIC-FI-SE\0csEBCDICFISE\0EBCDIC-FI-SE-" |
| 769 | "A\0csEBCDICFISEA\0EBCDIC-FR\0csEBCDICFR\0EBCDIC-IT\0csEBCDICIT\0EBCDIC-PT\0csEBCDICPT\0EBCDIC-" |
| 770 | "ES\0csEBCDICES\0EBCDIC-ES-A\0csEBCDICESA\0EBCDIC-ES-S\0csEBCDICESS\0EBCDIC-UK\0csEBCDICUK\0EBCDIC-" |
| 771 | "US\0csEBCDICUS\0UNKNOWN-" |
| 772 | "8BIT\0csUnknown8BiT\0MNEMONIC\0csMnemonic\0MNEM\0csMnem\0VISCII\0csVISCII\0VIQR\0csVIQR\0KOI8-R\0csKOI8R\0HZ-GB-" |
| 773 | "2312\0IBM866\0cp866\0866\0csIBM866\0IBM775\0cp775\0csPC775Baltic\0KOI8-" |
| 774 | "U\0csKOI8U\0IBM00858\0CCSID00858\0CP00858\0PC-Multilingual-850+" |
| 775 | "euro\0csIBM00858\0IBM00924\0CCSID00924\0CP00924\0ebcdic-Latin9--" |
| 776 | "euro\0csIBM00924\0IBM01140\0CCSID01140\0CP01140\0ebcdic-us-37+" |
| 777 | "euro\0csIBM01140\0IBM01141\0CCSID01141\0CP01141\0ebcdic-de-273+" |
| 778 | "euro\0csIBM01141\0IBM01142\0CCSID01142\0CP01142\0ebcdic-dk-277+euro\0ebcdic-no-277+" |
| 779 | "euro\0csIBM01142\0IBM01143\0CCSID01143\0CP01143\0ebcdic-fi-278+euro\0ebcdic-se-278+" |
| 780 | "euro\0csIBM01143\0IBM01144\0CCSID01144\0CP01144\0ebcdic-it-280+" |
| 781 | "euro\0csIBM01144\0IBM01145\0CCSID01145\0CP01145\0ebcdic-es-284+" |
| 782 | "euro\0csIBM01145\0IBM01146\0CCSID01146\0CP01146\0ebcdic-gb-285+" |
| 783 | "euro\0csIBM01146\0IBM01147\0CCSID01147\0CP01147\0ebcdic-fr-297+" |
| 784 | "euro\0csIBM01147\0IBM01148\0CCSID01148\0CP01148\0ebcdic-international-500+" |
| 785 | "euro\0csIBM01148\0IBM01149\0CCSID01149\0CP01149\0ebcdic-is-871+euro\0csIBM01149\0Big5-" |
| 786 | "HKSCS\0csBig5HKSCS\0IBM1047\0IBM-1047\0csIBM1047\0PTCP154\0csPTCP154\0PT154\0CP154\0Cyrillic-Asian\0Amiga-" |
| 787 | "1251\0Ami1251\0Amiga1251\0Ami-1251\0csAmiga1251\0KOI7-" |
| 788 | "switched\0csKOI7switched\0BRF\0csBRF\0TSCII\0csTSCII\0CP51932\0csCP51932\0windows-874\0cswindows874\0windows-" |
| 789 | "1250\0cswindows1250\0windows-1251\0cswindows1251\0windows-1252\0cswindows1252\0windows-" |
| 790 | "1253\0cswindows1253\0windows-1254\0cswindows1254\0windows-1255\0cswindows1255\0windows-" |
| 791 | "1256\0cswindows1256\0windows-1257\0cswindows1257\0windows-1258\0cswindows1258\0TIS-620\0csTIS620\0ISO-8859-" |
| 792 | "11\0CP50220\0csCP50220\0" ; |
| 793 | |
| 794 | struct __offset_table { |
| 795 | constexpr static unsigned long long __num_aliases = |
| 796 | std::count(first: __aliases_string, last: __aliases_string + sizeof(__aliases_string), value: '\0') + 1; |
| 797 | unsigned short __table[__num_aliases]; |
| 798 | }; |
| 799 | |
| 800 | static constexpr __offset_table __alias_offsets = [] { |
| 801 | __offset_table __aliases{}; |
| 802 | __aliases.__table[0] = sizeof(__aliases_string) - 1; |
| 803 | __aliases.__table[1] = sizeof(__aliases_string) - 1; |
| 804 | __aliases.__table[2] = 0; |
| 805 | |
| 806 | unsigned long long __idx = 3; |
| 807 | |
| 808 | for (unsigned short __pos = 0; __pos < sizeof(__aliases_string) - 1 && __idx < __offset_table::__num_aliases; |
| 809 | __pos++) { |
| 810 | if (__aliases_string[__pos] == '\0') { |
| 811 | __aliases.__table[__idx++] = __pos + 1; |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | return __aliases; |
| 816 | }(); |
| 817 | }; |
| 818 | |
| 819 | template <> |
| 820 | struct hash<text_encoding> { |
| 821 | [[nodiscard]] static size_t operator()(const text_encoding& __enc) noexcept { |
| 822 | return std::hash<std::text_encoding::id>()(__enc.mib()); |
| 823 | } |
| 824 | }; |
| 825 | |
| 826 | template <> |
| 827 | inline constexpr bool ranges::enable_borrowed_range<text_encoding::aliases_view> = true; |
| 828 | |
| 829 | _LIBCPP_END_NAMESPACE_STD |
| 830 | |
| 831 | # endif // _LIBCPP_STD_VER >= 26 |
| 832 | |
| 833 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 834 | |
| 835 | #endif // _LIBCPP_TEXT_ENCODING |
| 836 | |