// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_TEXT_ENCODING
#define _LIBCPP_TEXT_ENCODING

/* text_encoding synopsis
namespace std {

struct text_encoding;

// [text.encoding.hash], hash support
template<class T> struct hash;
template<> struct hash<text_encoding>;

struct text_encoding
{
    static constexpr size_t max_name_length = 63;

    // [text.encoding.id], enumeration text_encoding::id
    enum class id : int_least32_t {
      see below
    };
    using enum id;

    constexpr text_encoding() = default;
    constexpr explicit text_encoding(string_view enc) noexcept;
    constexpr text_encoding(id i) noexcept;

    constexpr id mib() const noexcept;
    constexpr const char* name() const noexcept;

    // [text.encoding.aliases], class text_encoding::aliases_view
    // struct aliases_view;
    constexpr aliases_view aliases() const noexcept;

    friend constexpr bool operator==(const text_encoding& a,
                                     const text_encoding& b) noexcept;
    friend constexpr bool operator==(const text_encoding& encoding, id i) noexcept;

    static consteval text_encoding literal() noexcept;
    static text_encoding environment();
    template<id i> static bool environment_is();

  private:
    id mib_ = id::unknown;                                              // exposition only
    char name_[max_name_length + 1] = {0};                              // exposition only
    static constexpr bool comp-name(string_view a, string_view b);      // exposition only
};
}

*/

#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
#  include <__cxx03/__config>
#else
#  include <__config>

#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#    pragma GCC system_header
#  endif

#  if _LIBCPP_STD_VER >= 26

#    include <__algorithm/count.h>
#    include <__algorithm/find_if.h>
#    include <__algorithm/lower_bound.h>
#    include <__cstddef/ptrdiff_t.h>
#    include <__functional/hash.h>
#    include <__iterator/iterator_traits.h>
#    include <__ranges/enable_borrowed_range.h>
#    include <__ranges/view_interface.h>
#    include <climits>
#    include <cstdint>
#    include <string_view>
#    include <version>

_LIBCPP_BEGIN_NAMESPACE_STD
struct text_encoding;

_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS

_LIBCPP_AVAILABILITY_TEXT_ENCODING_ENVIRONMENT _LIBCPP_EXPORTED_FROM_ABI text_encoding
__get_locale_encoding(const char* __name);

_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS

struct text_encoding {
  static_assert(CHAR_BIT == 8, "libc++ only supports platforms where CHAR_BIT == 8");
  enum class id : int_least32_t {
    other                   = 1,
    unknown                 = 2,
    ASCII                   = 3,
    ISOLatin1               = 4,
    ISOLatin2               = 5,
    ISOLatin3               = 6,
    ISOLatin4               = 7,
    ISOLatinCyrillic        = 8,
    ISOLatinArabic          = 9,
    ISOLatinGreek           = 10,
    ISOLatinHebrew          = 11,
    ISOLatin5               = 12,
    ISOLatin6               = 13,
    ISOTextComm             = 14,
    HalfWidthKatakana       = 15,
    JISEncoding             = 16,
    ShiftJIS                = 17,
    EUCPkdFmtJapanese       = 18,
    EUCFixWidJapanese       = 19,
    ISO4UnitedKingdom       = 20,
    ISO11SwedishForNames    = 21,
    ISO15Italian            = 22,
    ISO17Spanish            = 23,
    ISO21German             = 24,
    ISO60DanishNorwegian    = 25,
    ISO69French             = 26,
    ISO10646UTF1            = 27,
    ISO646basic1983         = 28,
    INVARIANT               = 29,
    ISO2IntlRefVersion      = 30,
    NATSSEFI                = 31,
    NATSSEFIADD             = 32, // NATS-DANO (33) and NATS-DANO-ADD (34) are omitted by the standard.
    ISO10Swedish            = 35,
    KSC56011987             = 36,
    ISO2022KR               = 37,
    EUCKR                   = 38,
    ISO2022JP               = 39,
    ISO2022JP2              = 40,
    ISO13JISC6220jp         = 41,
    ISO14JISC6220ro         = 42,
    ISO16Portuguese         = 43,
    ISO18Greek7Old          = 44,
    ISO19LatinGreek         = 45,
    ISO25French             = 46,
    ISO27LatinGreek1        = 47,
    ISO5427Cyrillic         = 48,
    ISO42JISC62261978       = 49,
    ISO47BSViewdata         = 50,
    ISO49INIS               = 51,
    ISO50INIS8              = 52,
    ISO51INISCyrillic       = 53,
    ISO54271981             = 54,
    ISO5428Greek            = 55,
    ISO57GB1988             = 56,
    ISO58GB231280           = 57,
    ISO61Norwegian2         = 58,
    ISO70VideotexSupp1      = 59,
    ISO84Portuguese2        = 60,
    ISO85Spanish2           = 61,
    ISO86Hungarian          = 62,
    ISO87JISX0208           = 63,
    ISO88Greek7             = 64,
    ISO89ASMO449            = 65,
    ISO90                   = 66,
    ISO91JISC62291984a      = 67,
    ISO92JISC62991984b      = 68,
    ISO93JIS62291984badd    = 69,
    ISO94JIS62291984hand    = 70,
    ISO95JIS62291984handadd = 71,
    ISO96JISC62291984kana   = 72,
    ISO2033                 = 73,
    ISO99NAPLPS             = 74,
    ISO102T617bit           = 75,
    ISO103T618bit           = 76,
    ISO111ECMACyrillic      = 77,
    ISO121Canadian1         = 78,
    ISO122Canadian2         = 79,
    ISO123CSAZ24341985gr    = 80,
    ISO88596E               = 81,
    ISO88596I               = 82,
    ISO128T101G2            = 83,
    ISO88598E               = 84,
    ISO88598I               = 85,
    ISO139CSN369103         = 86,
    ISO141JUSIB1002         = 87,
    ISO143IECP271           = 88,
    ISO146Serbian           = 89,
    ISO147Macedonian        = 90,
    ISO150                  = 91,
    ISO151Cuba              = 92,
    ISO6937Add              = 93,
    ISO153GOST1976874       = 94,
    ISO8859Supp             = 95,
    ISO10367Box             = 96,
    ISO158Lap               = 97,
    ISO159JISX02121990      = 98,
    ISO646Danish            = 99,
    USDK                    = 100,
    DKUS                    = 101,
    KSC5636                 = 102,
    Unicode11UTF7           = 103,
    ISO2022CN               = 104,
    ISO2022CNEXT            = 105,
    UTF8                    = 106,
    ISO885913               = 109,
    ISO885914               = 110,
    ISO885915               = 111,
    ISO885916               = 112,
    GBK                     = 113,
    GB18030                 = 114,
    OSDEBCDICDF0415         = 115,
    OSDEBCDICDF03IRV        = 116,
    OSDEBCDICDF041          = 117,
    ISO115481               = 118,
    KZ1048                  = 119,
    UCS2                    = 1000,
    UCS4                    = 1001,
    UnicodeASCII            = 1002,
    UnicodeLatin1           = 1003,
    UnicodeJapanese         = 1004,
    UnicodeIBM1261          = 1005,
    UnicodeIBM1268          = 1006,
    UnicodeIBM1276          = 1007,
    UnicodeIBM1264          = 1008,
    UnicodeIBM1265          = 1009,
    Unicode11               = 1010,
    SCSU                    = 1011,
    UTF7                    = 1012,
    UTF16BE                 = 1013,
    UTF16LE                 = 1014,
    UTF16                   = 1015,
    CESU8                   = 1016,
    UTF32                   = 1017,
    UTF32BE                 = 1018,
    UTF32LE                 = 1019,
    BOCU1                   = 1020,
    UTF7IMAP                = 1021,
    Windows30Latin1         = 2000,
    Windows31Latin1         = 2001,
    Windows31Latin2         = 2002,
    Windows31Latin5         = 2003,
    HPRoman8                = 2004,
    AdobeStandardEncoding   = 2005,
    VenturaUS               = 2006,
    VenturaInternational    = 2007,
    DECMCS                  = 2008,
    PC850Multilingual       = 2009,
    PC8DanishNorwegian      = 2012,
    PC862LatinHebrew        = 2013,
    PC8Turkish              = 2014,
    IBMSymbols              = 2015,
    IBMThai                 = 2016,
    HPLegal                 = 2017,
    HPPiFont                = 2018,
    HPMath8                 = 2019,
    HPPSMath                = 2020,
    HPDesktop               = 2021,
    VenturaMath             = 2022,
    MicrosoftPublishing     = 2023,
    Windows31J              = 2024,
    GB2312                  = 2025,
    Big5                    = 2026,
    Macintosh               = 2027,
    IBM037                  = 2028,
    IBM038                  = 2029,
    IBM273                  = 2030,
    IBM274                  = 2031,
    IBM275                  = 2032,
    IBM277                  = 2033,
    IBM278                  = 2034,
    IBM280                  = 2035,
    IBM281                  = 2036,
    IBM284                  = 2037,
    IBM285                  = 2038,
    IBM290                  = 2039,
    IBM297                  = 2040,
    IBM420                  = 2041,
    IBM423                  = 2042,
    IBM424                  = 2043,
    PC8CodePage437          = 2011,
    IBM500                  = 2044,
    IBM851                  = 2045,
    PCp852                  = 2010,
    IBM855                  = 2046,
    IBM857                  = 2047,
    IBM860                  = 2048,
    IBM861                  = 2049,
    IBM863                  = 2050,
    IBM864                  = 2051,
    IBM865                  = 2052,
    IBM868                  = 2053,
    IBM869                  = 2054,
    IBM870                  = 2055,
    IBM871                  = 2056,
    IBM880                  = 2057,
    IBM891                  = 2058,
    IBM903                  = 2059,
    IBM904                  = 2060,
    IBM905                  = 2061,
    IBM918                  = 2062,
    IBM1026                 = 2063,
    IBMEBCDICATDE           = 2064,
    EBCDICATDEA             = 2065,
    EBCDICCAFR              = 2066,
    EBCDICDKNO              = 2067,
    EBCDICDKNOA             = 2068,
    EBCDICFISE              = 2069,
    EBCDICFISEA             = 2070,
    EBCDICFR                = 2071,
    EBCDICIT                = 2072,
    EBCDICPT                = 2073,
    EBCDICES                = 2074,
    EBCDICESA               = 2075,
    EBCDICESS               = 2076,
    EBCDICUK                = 2077,
    EBCDICUS                = 2078,
    Unknown8BiT             = 2079,
    Mnemonic                = 2080,
    Mnem                    = 2081,
    VISCII                  = 2082,
    VIQR                    = 2083,
    KOI8R                   = 2084,
    HZGB2312                = 2085,
    IBM866                  = 2086,
    PC775Baltic             = 2087,
    KOI8U                   = 2088,
    IBM00858                = 2089,
    IBM00924                = 2090,
    IBM01140                = 2091,
    IBM01141                = 2092,
    IBM01142                = 2093,
    IBM01143                = 2094,
    IBM01144                = 2095,
    IBM01145                = 2096,
    IBM01146                = 2097,
    IBM01147                = 2098,
    IBM01148                = 2099,
    IBM01149                = 2100,
    Big5HKSCS               = 2101,
    IBM1047                 = 2102,
    PTCP154                 = 2103,
    Amiga1251               = 2104,
    KOI7switched            = 2105,
    BRF                     = 2106,
    TSCII                   = 2107,
    CP51932                 = 2108,
    windows874              = 2109,
    windows1250             = 2250,
    windows1251             = 2251,
    windows1252             = 2252,
    windows1253             = 2253,
    windows1254             = 2254,
    windows1255             = 2255,
    windows1256             = 2256,
    windows1257             = 2257,
    windows1258             = 2258,
    TIS620                  = 2259,
    CP50220                 = 2260
  };

private:
  static constexpr int __nats_dano_     = 33;
  static constexpr int __nats_dano_add_ = 34;

  // A __te_data structure stores:
  // Index into a table of offsets in the giant aliases string
  // The MIB of that text encoding
  // Number of aliases the current MIB holds
  // We only need 6 bytes of information to store this information.

  // The data is structured in three different locations:
  // The mib table (array of __te_data)
  // Aliases string
  // Table of offsets into the aliases string

  // All of the alias strings were transformed from an array of char* into one giant string split by '\0'.
  // This allows us to reduce runtime memory footprint by not only removing the need to store ~884 pointers, it also
  // significantly reduces the disk space taken by removing the need for relocation data for those pointers.
  // We also know ahead of time that the total number of characters of all of these aliases combined can fit into 2
  // bytes, so we can also save even more memory by using 2 byte offsets rather than a full pointer into the aliases
  // string.

  struct __te_data {
    unsigned short __first_alias_index_;
    unsigned short __mib_rep_;
    unsigned char __num_aliases_;

    friend constexpr bool operator<(const __te_data& __enc, id __i) noexcept {
      return __enc.__mib_rep_ < static_cast<unsigned short>(__i);
    }
  };

  static constexpr bool __comp_name(string_view __a, string_view __b) noexcept {
    if (__a.empty() || __b.empty()) {
      return false;
    }

    // Map any non-alphanumeric character to 255, skip prefix 0s, else get tolower(__n).
    auto __map_char = [](char __n, bool& __in_number) -> unsigned char {
      if (__n == '0') {
        return __in_number ? '0' : 255;
      }
      __in_number = __n >= '1' && __n <= '9';

      if ((__n >= '1' && __n <= '9') || (__n >= 'a' && __n <= 'z')) {
        return __n;
      }
      if (__n >= 'A' && __n <= 'Z') {
        return __n + ('a' - 'A'); // tolower
      }

      return 255;
    };

    auto __a_ptr = __a.begin(), __b_ptr = __b.begin();
    bool __a_in_number = false, __b_in_number = false;

    unsigned char __a_val = 255, __b_val = 255;
    for (;; __a_ptr++, __b_ptr++) {
      while (__a_ptr != __a.end() && (__a_val = __map_char(*__a_ptr, __a_in_number)) == 255)
        __a_ptr++;
      while (__b_ptr != __b.end() && (__b_val = __map_char(*__b_ptr, __b_in_number)) == 255)
        __b_ptr++;

      if (__a_ptr == __a.end())
        return __b_ptr == __b.end();
      if (__b_ptr == __b.end())
        return false;
      if (__a_val != __b_val)
        return false;
    }
    return true;
  }

  static constexpr unsigned short __find_data_idx(string_view __a) noexcept {
    _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__a.size() <= max_name_length, "input string_view must have size <= 63");
    _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__a.contains('\0'), "input string_view must not contain '\\0'");

    auto __pred = [&__a](const __te_data& __entry) -> bool {
      // Search aliases of text encoding for string
      aliases_view __aliases(__entry);
      return std::find_if(__aliases.begin(), __aliases.end(), [&__a](auto __alias) {
               return __comp_name(__a, __alias);
             }) != __aliases.end();
    };

    const __te_data* __found = std::find_if(__entries + 2, std::end(__entries), __pred);
    if (__found == std::end(__entries)) {
      return __other_idx_; // other
    }

    return __found - __entries;
  }

  static constexpr unsigned short __find_data_idx_by_id(id __i) noexcept {
    _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__i >= id::other, "invalid text_encoding::id passed");
    _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__i <= id::CP50220, "invalid text_encoding::id passed");
    _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(int_least32_t(__i) != __nats_dano_, "Mib for NATS-DANO used");
    _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(int_least32_t(__i) != __nats_dano_add_, "Mib for NATS-DANO-ADD used");
    auto __found = std::lower_bound(std::begin(__entries), std::end(__entries), __i);

    if (__found == std::end(__entries)) {
      return __unknown_idx_; // unknown
    }

    return __found - __entries;
  }

public:
  using enum id;
  static constexpr size_t max_name_length = 63;

  // [text.encoding.aliases], class text_encoding::aliases_view
  struct aliases_view : ranges::view_interface<aliases_view> {
    struct __iterator {
      using iterator_concept  = random_access_iterator_tag;
      using iterator_category = random_access_iterator_tag;
      using value_type        = const char*;
      using reference         = const char*;
      using difference_type   = int;

      constexpr __iterator() noexcept = default;

      [[nodiscard]] constexpr reference operator*() const noexcept {
        return __get_alias_from_offset_table(__current_idx_);
      }

      [[nodiscard]] constexpr reference operator[](difference_type __n) const noexcept {
        auto __it = *this;
        return *(__it + __n);
      }

      [[nodiscard]] friend constexpr __iterator operator+(__iterator __it, difference_type __n) noexcept {
        __it += __n;
        return __it;
      }

      [[nodiscard]] friend constexpr __iterator operator+(difference_type __n, __iterator __it) noexcept {
        __it += __n;
        return __it;
      }

      [[nodiscard]] friend constexpr __iterator operator-(__iterator __it, difference_type __n) noexcept {
        __it -= __n;
        return __it;
      }

      [[nodiscard]] constexpr difference_type operator-(const __iterator& __other) const noexcept {
        return __current_idx_ - __other.__current_idx_;
      }

      constexpr __iterator& operator++() noexcept {
        __current_idx_++;
        return *this;
      }

      constexpr __iterator operator++(int) noexcept {
        auto __old = *this;
        __current_idx_++;
        return __old;
      }

      constexpr __iterator& operator--() noexcept {
        __current_idx_--;
        return *this;
      }

      constexpr __iterator operator--(int) noexcept {
        auto __old = *this;
        __current_idx_--;
        return __old;
      }

      constexpr __iterator& operator+=(difference_type __n) noexcept {
        __current_idx_ += __n;
        return *this;
      }

      constexpr __iterator& operator-=(difference_type __n) noexcept { return (*this += -__n); }

      friend constexpr auto operator<=>(const __iterator& __it, const __iterator& __it2) noexcept = default;

    private:
      friend struct aliases_view;

      constexpr __iterator(unsigned short __enc_d) noexcept : __current_idx_(__enc_d) {}

      unsigned short __current_idx_;
    }; // __iterator

    [[nodiscard]] constexpr __iterator begin() const noexcept { return __iterator(__first_idx_); }

    [[nodiscard]] constexpr __iterator end() const noexcept { return __iterator(__last_idx_); }

  private:
    friend struct text_encoding;

    constexpr aliases_view(const __te_data& __d)
        : __first_idx_(__d.__first_alias_index_), __last_idx_(__d.__first_alias_index_ + __d.__num_aliases_) {}

    unsigned short __first_idx_;
    unsigned short __last_idx_;
  }; // aliases_view

  constexpr text_encoding() = default;

  constexpr explicit text_encoding(string_view __enc) noexcept : __encoding_idx_(__find_data_idx(__enc)) {
    __enc.copy(__name_, max_name_length, 0);
  }

  constexpr text_encoding(id __i) noexcept : __encoding_idx_(__find_data_idx_by_id(__i)) {
    const char* __alias = __get_alias_from_offset_table(__get().__first_alias_index_);
    if (__alias[0] != '\0') {
      string_view(__alias).copy(__name_, max_name_length);
    }
  }

  [[nodiscard]] constexpr id mib() const noexcept { return id(__get().__mib_rep_); }

  [[nodiscard]] constexpr const char* name() const noexcept { return __name_; }

  [[nodiscard]] constexpr aliases_view aliases() const noexcept { return aliases_view(__get()); }

  friend constexpr bool operator==(const text_encoding& __a, const text_encoding& __b) noexcept {
    return __a.mib() == id::other && __b.mib() == id::other
             ? __comp_name(__a.__name_, __b.__name_)
             : __a.mib() == __b.mib();
  }

  friend constexpr bool operator==(const text_encoding& __encoding, id __i) noexcept { return __encoding.mib() == __i; }

  [[nodiscard]] static consteval text_encoding literal() noexcept {
    // TODO: Remove this branch once we have __GNUC_EXECUTION_CHARSET_NAME or __clang_literal_encoding__ unconditionally
#    ifdef __GNUC_EXECUTION_CHARSET_NAME
    return text_encoding(__GNUC_EXECUTION_CHARSET_NAME);
#    elif defined(__clang_literal_encoding__)
    return text_encoding(__clang_literal_encoding__);
#    else
    return text_encoding();
#    endif
  }

#    if _LIBCPP_HAS_LOCALIZATION
  [[nodiscard]] _LIBCPP_AVAILABILITY_TEXT_ENCODING_ENVIRONMENT static text_encoding environment() {
#      if defined(_LIBCPP_WIN32API)
    return __get_locale_encoding(nullptr);
#      else
    return __get_locale_encoding("");
#      endif
  }

  template <id _Id>
  [[nodiscard]] _LIBCPP_AVAILABILITY_TEXT_ENCODING_ENVIRONMENT static bool environment_is() {
    // TODO: It may be worthwhile to implement an optimization for popular encodings, e.g. UTF-8,
    // to allow checking the environment text encoding without needing to use the data tables.

#      if defined(__ANDROID__)
    return _Id == std::text_encoding::id::UTF8;
#      else
    return environment() == _Id;
#      endif
  }
#    else
  static text_encoding environment() = delete;

  template <id>
  static bool environment_is() = delete;
#    endif

private:
  constexpr const __te_data& __get() const { return __entries[__encoding_idx_]; }

  static constexpr char const* __get_alias_from_offset_table(unsigned short __idx) {
    return __aliases_string + __alias_offsets.__table[__idx];
  }

  static constexpr auto __other_idx_   = 0u;
  static constexpr auto __unknown_idx_ = 1u;

  char __name_[max_name_length + 1]{};
  unsigned short __encoding_idx_{1u};

  static constexpr __te_data __entries[] = {
      {0, 1, 0},      {1, 2, 0},      {2, 3, 11},     {13, 4, 9},     {22, 5, 7},     {29, 6, 7},     {36, 7, 7},
      {43, 8, 6},     {49, 9, 8},     {57, 10, 9},    {66, 11, 6},    {72, 12, 7},    {79, 13, 6},    {85, 14, 3},
      {88, 15, 3},    {91, 16, 2},    {93, 17, 3},    {96, 18, 3},    {99, 19, 2},    {101, 20, 6},   {107, 21, 5},
      {112, 22, 4},   {116, 23, 4},   {120, 24, 5},   {125, 25, 6},   {131, 26, 5},   {136, 27, 2},   {138, 28, 3},
      {141, 29, 2},   {143, 30, 4},   {147, 31, 3},   {150, 32, 3},   {153, 35, 7},   {160, 36, 6},   {166, 37, 2},
      {168, 38, 2},   {170, 39, 2},   {172, 40, 2},   {174, 41, 6},   {180, 42, 5},   {185, 43, 4},   {189, 44, 3},
      {192, 45, 3},   {195, 46, 4},   {199, 47, 3},   {202, 48, 3},   {205, 49, 3},   {208, 50, 3},   {211, 51, 3},
      {214, 52, 3},   {217, 53, 3},   {220, 54, 4},   {224, 55, 3},   {227, 56, 5},   {232, 57, 4},   {236, 58, 5},
      {241, 59, 3},   {244, 60, 4},   {248, 61, 4},   {252, 62, 5},   {257, 63, 5},   {262, 64, 3},   {265, 65, 5},
      {270, 66, 2},   {272, 67, 4},   {276, 68, 5},   {281, 69, 4},   {285, 70, 4},   {289, 71, 4},   {293, 72, 3},
      {296, 73, 4},   {300, 74, 5},   {305, 75, 3},   {308, 76, 4},   {312, 77, 4},   {316, 78, 7},   {323, 79, 6},
      {329, 80, 3},   {332, 81, 3},   {335, 82, 3},   {338, 83, 3},   {341, 84, 3},   {344, 85, 3},   {347, 86, 3},
      {350, 87, 6},   {356, 88, 3},   {359, 89, 4},   {363, 90, 4},   {367, 91, 4},   {371, 92, 5},   {376, 93, 3},
      {379, 94, 4},   {383, 95, 4},   {387, 96, 3},   {390, 97, 4},   {394, 98, 4},   {398, 99, 5},   {403, 100, 2},
      {405, 101, 2},  {407, 102, 3},  {410, 103, 2},  {412, 104, 2},  {414, 105, 2},  {416, 106, 2},  {418, 109, 2},
      {420, 110, 8},  {428, 111, 4},  {432, 112, 7},  {439, 113, 5},  {444, 114, 2},  {446, 115, 2},  {448, 116, 2},
      {450, 117, 2},  {452, 118, 4},  {456, 119, 4},  {460, 1000, 2}, {462, 1001, 2}, {464, 1002, 2}, {466, 1003, 3},
      {469, 1004, 2}, {471, 1005, 2}, {473, 1006, 2}, {475, 1007, 2}, {477, 1008, 2}, {479, 1009, 2}, {481, 1010, 2},
      {483, 1011, 2}, {485, 1012, 2}, {487, 1013, 2}, {489, 1014, 2}, {491, 1015, 2}, {493, 1016, 3}, {496, 1017, 2},
      {498, 1018, 2}, {500, 1019, 2}, {502, 1020, 3}, {505, 1021, 2}, {507, 2000, 2}, {509, 2001, 2}, {511, 2002, 2},
      {513, 2003, 2}, {515, 2004, 4}, {519, 2005, 2}, {521, 2006, 2}, {523, 2007, 2}, {525, 2008, 3}, {528, 2009, 4},
      {532, 2010, 4}, {536, 2011, 4}, {540, 2012, 2}, {542, 2013, 4}, {546, 2014, 2}, {548, 2015, 2}, {550, 2016, 2},
      {552, 2017, 2}, {554, 2018, 2}, {556, 2019, 2}, {558, 2020, 2}, {560, 2021, 2}, {562, 2022, 2}, {564, 2023, 2},
      {566, 2024, 2}, {568, 2025, 2}, {570, 2026, 2}, {572, 2027, 3}, {575, 2028, 7}, {582, 2029, 4}, {586, 2030, 3},
      {589, 2031, 4}, {593, 2032, 4}, {597, 2033, 4}, {601, 2034, 5}, {606, 2035, 4}, {610, 2036, 4}, {614, 2037, 4},
      {618, 2038, 4}, {622, 2039, 4}, {626, 2040, 4}, {630, 2041, 4}, {634, 2042, 4}, {638, 2043, 4}, {642, 2044, 5},
      {647, 2045, 4}, {651, 2046, 4}, {655, 2047, 4}, {659, 2048, 4}, {663, 2049, 5}, {668, 2050, 4}, {672, 2051, 3},
      {675, 2052, 4}, {679, 2053, 4}, {683, 2054, 5}, {688, 2055, 5}, {693, 2056, 4}, {697, 2057, 4}, {701, 2058, 3},
      {704, 2059, 3}, {707, 2060, 4}, {711, 2061, 4}, {715, 2062, 4}, {719, 2063, 3}, {722, 2064, 2}, {724, 2065, 2},
      {726, 2066, 2}, {728, 2067, 2}, {730, 2068, 2}, {732, 2069, 2}, {734, 2070, 2}, {736, 2071, 2}, {738, 2072, 2},
      {740, 2073, 2}, {742, 2074, 2}, {744, 2075, 2}, {746, 2076, 2}, {748, 2077, 2}, {750, 2078, 2}, {752, 2079, 2},
      {754, 2080, 2}, {756, 2081, 2}, {758, 2082, 2}, {760, 2083, 2}, {762, 2084, 2}, {764, 2085, 1}, {765, 2086, 4},
      {769, 2087, 3}, {772, 2088, 2}, {774, 2089, 5}, {779, 2090, 5}, {784, 2091, 5}, {789, 2092, 5}, {794, 2093, 6},
      {800, 2094, 6}, {806, 2095, 5}, {811, 2096, 5}, {816, 2097, 5}, {821, 2098, 5}, {826, 2099, 5}, {831, 2100, 5},
      {836, 2101, 2}, {838, 2102, 3}, {841, 2103, 5}, {846, 2104, 5}, {851, 2105, 2}, {853, 2106, 2}, {855, 2107, 2},
      {857, 2108, 2}, {859, 2109, 2}, {861, 2250, 2}, {863, 2251, 2}, {865, 2252, 2}, {867, 2253, 2}, {869, 2254, 2},
      {871, 2255, 2}, {873, 2256, 2}, {875, 2257, 2}, {877, 2258, 2}, {879, 2259, 3}, {882, 2260, 2}};

  static constexpr char __aliases_string[] =
      "US-ASCII\0iso-ir-6\0ANSI_X3.4-1968\0ANSI_X3.4-1986\0ISO_646.irv:1991\0ISO646-"
      "US\0us\0IBM367\0cp367\0csASCII\0ASCII\0ISO_8859-1:1987\0iso-ir-100\0ISO_8859-1\0ISO-8859-"
      "1\0latin1\0l1\0IBM819\0CP819\0csISOLatin1\0ISO_8859-2:1987\0iso-ir-101\0ISO_8859-2\0ISO-8859-"
      "2\0latin2\0l2\0csISOLatin2\0ISO_8859-3:1988\0iso-ir-109\0ISO_8859-3\0ISO-8859-3\0latin3\0l3\0csISOLatin3\0ISO_"
      "8859-4:1988\0iso-ir-110\0ISO_8859-4\0ISO-8859-4\0latin4\0l4\0csISOLatin4\0ISO_8859-5:1988\0iso-ir-144\0ISO_8859-"
      "5\0ISO-8859-5\0cyrillic\0csISOLatinCyrillic\0ISO_8859-6:1987\0iso-ir-127\0ISO_8859-6\0ISO-8859-6\0ECMA-"
      "114\0ASMO-708\0arabic\0csISOLatinArabic\0ISO_8859-7:1987\0iso-ir-126\0ISO_8859-7\0ISO-8859-7\0ELOT_928\0ECMA-"
      "118\0greek\0greek8\0csISOLatinGreek\0ISO_8859-8:1988\0iso-ir-138\0ISO_8859-8\0ISO-8859-"
      "8\0hebrew\0csISOLatinHebrew\0ISO_8859-9:1989\0iso-ir-148\0ISO_8859-9\0ISO-8859-9\0latin5\0l5\0csISOLatin5\0ISO-"
      "8859-10\0iso-ir-157\0l6\0ISO_8859-10:1992\0csISOLatin6\0latin6\0ISO_6937-2-add\0iso-ir-142\0csISOTextComm\0JIS_"
      "X0201\0X0201\0csHalfWidthKatakana\0JIS_Encoding\0csJISEncoding\0Shift_JIS\0MS_Kanji\0csShiftJIS\0Extended_UNIX_"
      "Code_Packed_Format_for_Japanese\0csEUCPkdFmtJapanese\0EUC-JP\0Extended_UNIX_Code_Fixed_Width_for_"
      "Japanese\0csEUCFixWidJapanese\0BS_4730\0iso-ir-4\0ISO646-GB\0gb\0uk\0csISO4UnitedKingdom\0SEN_850200_C\0iso-ir-"
      "11\0ISO646-SE2\0se2\0csISO11SwedishForNames\0IT\0iso-ir-15\0ISO646-IT\0csISO15Italian\0ES\0iso-ir-17\0ISO646-"
      "ES\0csISO17Spanish\0DIN_66003\0iso-ir-21\0de\0ISO646-DE\0csISO21German\0NS_4551-1\0iso-ir-60\0ISO646-"
      "NO\0no\0csISO60DanishNorwegian\0csISO60Norwegian1\0NF_Z_62-010\0iso-ir-69\0ISO646-FR\0fr\0csISO69French\0ISO-"
      "10646-UTF-1\0csISO10646UTF1\0ISO_646.basic:1983\0ref\0csISO646basic1983\0INVARIANT\0csINVARIANT\0ISO_646.irv:"
      "1983\0iso-ir-2\0irv\0csISO2IntlRefVersion\0NATS-SEFI\0iso-ir-8-1\0csNATSSEFI\0NATS-SEFI-ADD\0iso-ir-8-"
      "2\0csNATSSEFIADD\0SEN_850200_B\0iso-ir-10\0FI\0ISO646-FI\0ISO646-SE\0se\0csISO10Swedish\0KS_C_5601-1987\0iso-ir-"
      "149\0KS_C_5601-1989\0KSC_5601\0korean\0csKSC56011987\0ISO-2022-KR\0csISO2022KR\0EUC-KR\0csEUCKR\0ISO-2022-"
      "JP\0csISO2022JP\0ISO-2022-JP-2\0csISO2022JP2\0JIS_C6220-1969-jp\0JIS_C6220-1969\0iso-ir-13\0katakana\0x0201-"
      "7\0csISO13JISC6220jp\0JIS_C6220-1969-ro\0iso-ir-14\0jp\0ISO646-JP\0csISO14JISC6220ro\0PT\0iso-ir-16\0ISO646-"
      "PT\0csISO16Portuguese\0greek7-old\0iso-ir-18\0csISO18Greek7Old\0latin-greek\0iso-ir-19\0csISO19LatinGreek\0NF_Z_"
      "62-010_(1973)\0iso-ir-25\0ISO646-FR1\0csISO25French\0Latin-greek-1\0iso-ir-27\0csISO27LatinGreek1\0ISO_"
      "5427\0iso-ir-37\0csISO5427Cyrillic\0JIS_C6226-1978\0iso-ir-42\0csISO42JISC62261978\0BS_viewdata\0iso-ir-"
      "47\0csISO47BSViewdata\0INIS\0iso-ir-49\0csISO49INIS\0INIS-8\0iso-ir-50\0csISO50INIS8\0INIS-cyrillic\0iso-ir-"
      "51\0csISO51INISCyrillic\0ISO_5427:1981\0iso-ir-54\0ISO5427Cyrillic1981\0csISO54271981\0ISO_5428:1980\0iso-ir-"
      "55\0csISO5428Greek\0GB_1988-80\0iso-ir-57\0cn\0ISO646-CN\0csISO57GB1988\0GB_2312-80\0iso-ir-"
      "58\0chinese\0csISO58GB231280\0NS_4551-2\0ISO646-NO2\0iso-ir-61\0no2\0csISO61Norwegian2\0videotex-suppl\0iso-ir-"
      "70\0csISO70VideotexSupp1\0PT2\0iso-ir-84\0ISO646-PT2\0csISO84Portuguese2\0ES2\0iso-ir-85\0ISO646-"
      "ES2\0csISO85Spanish2\0MSZ_7795.3\0iso-ir-86\0ISO646-HU\0hu\0csISO86Hungarian\0JIS_C6226-1983\0iso-ir-"
      "87\0x0208\0JIS_X0208-1983\0csISO87JISX0208\0greek7\0iso-ir-88\0csISO88Greek7\0ASMO_449\0ISO_9036\0arabic7\0iso-"
      "ir-89\0csISO89ASMO449\0iso-ir-90\0csISO90\0JIS_C6229-1984-a\0iso-ir-91\0jp-ocr-a\0csISO91JISC62291984a\0JIS_"
      "C6229-1984-b\0iso-ir-92\0ISO646-JP-OCR-B\0jp-ocr-b\0csISO92JISC62991984b\0JIS_C6229-1984-b-add\0iso-ir-93\0jp-"
      "ocr-b-add\0csISO93JIS62291984badd\0JIS_C6229-1984-hand\0iso-ir-94\0jp-ocr-hand\0csISO94JIS62291984hand\0JIS_"
      "C6229-1984-hand-add\0iso-ir-95\0jp-ocr-hand-add\0csISO95JIS62291984handadd\0JIS_C6229-1984-kana\0iso-ir-"
      "96\0csISO96JISC62291984kana\0ISO_2033-1983\0iso-ir-98\0e13b\0csISO2033\0ANSI_X3.110-1983\0iso-ir-99\0CSA_T500-"
      "1983\0NAPLPS\0csISO99NAPLPS\0T.61-7bit\0iso-ir-102\0csISO102T617bit\0T.61-8bit\0T.61\0iso-ir-"
      "103\0csISO103T618bit\0ECMA-cyrillic\0iso-ir-111\0KOI8-E\0csISO111ECMACyrillic\0CSA_Z243.4-1985-1\0iso-ir-"
      "121\0ISO646-CA\0csa7-1\0csa71\0ca\0csISO121Canadian1\0CSA_Z243.4-1985-2\0iso-ir-122\0ISO646-CA2\0csa7-"
      "2\0csa72\0csISO122Canadian2\0CSA_Z243.4-1985-gr\0iso-ir-123\0csISO123CSAZ24341985gr\0ISO_8859-6-"
      "E\0csISO88596E\0ISO-8859-6-E\0ISO_8859-6-I\0csISO88596I\0ISO-8859-6-I\0T.101-G2\0iso-ir-"
      "128\0csISO128T101G2\0ISO_8859-8-E\0csISO88598E\0ISO-8859-8-E\0ISO_8859-8-I\0csISO88598I\0ISO-8859-8-I\0CSN_"
      "369103\0iso-ir-139\0csISO139CSN369103\0JUS_I.B1.002\0iso-ir-141\0ISO646-YU\0js\0yu\0csISO141JUSIB1002\0IEC_P27-"
      "1\0iso-ir-143\0csISO143IECP271\0JUS_I.B1.003-serb\0iso-ir-146\0serbian\0csISO146Serbian\0JUS_I.B1.003-"
      "mac\0macedonian\0iso-ir-147\0csISO147Macedonian\0greek-ccitt\0iso-ir-150\0csISO150\0csISO150GreekCCITT\0NC_NC00-"
      "10:81\0cuba\0iso-ir-151\0ISO646-CU\0csISO151Cuba\0ISO_6937-2-25\0iso-ir-152\0csISO6937Add\0GOST_19768-74\0ST_"
      "SEV_358-88\0iso-ir-153\0csISO153GOST1976874\0ISO_8859-supp\0iso-ir-154\0latin1-2-5\0csISO8859Supp\0ISO_10367-"
      "box\0iso-ir-155\0csISO10367Box\0latin-lap\0lap\0iso-ir-158\0csISO158Lap\0JIS_X0212-1990\0x0212\0iso-ir-"
      "159\0csISO159JISX02121990\0DS_2089\0DS2089\0ISO646-DK\0dk\0csISO646Danish\0us-dk\0csUSDK\0dk-"
      "us\0csDKUS\0KSC5636\0ISO646-KR\0csKSC5636\0UNICODE-1-1-UTF-7\0csUnicode11UTF7\0ISO-2022-CN\0csISO2022CN\0ISO-"
      "2022-CN-EXT\0csISO2022CNEXT\0UTF-8\0csUTF8\0ISO-8859-13\0csISO885913\0ISO-8859-14\0iso-ir-199\0ISO_8859-14:"
      "1998\0ISO_8859-14\0latin8\0iso-celtic\0l8\0csISO885914\0ISO-8859-15\0ISO_8859-15\0Latin-9\0csISO885915\0ISO-"
      "8859-16\0iso-ir-226\0ISO_8859-16:2001\0ISO_8859-16\0latin10\0l10\0csISO885916\0GBK\0CP936\0MS936\0windows-"
      "936\0csGBK\0GB18030\0csGB18030\0OSD_EBCDIC_DF04_15\0csOSDEBCDICDF0415\0OSD_EBCDIC_DF03_"
      "IRV\0csOSDEBCDICDF03IRV\0OSD_EBCDIC_DF04_1\0csOSDEBCDICDF041\0ISO-11548-1\0ISO_11548-1\0ISO_TR_11548-"
      "1\0csISO115481\0KZ-1048\0STRK1048-2002\0RK1048\0csKZ1048\0ISO-10646-UCS-2\0csUnicode\0ISO-10646-UCS-"
      "4\0csUCS4\0ISO-10646-UCS-Basic\0csUnicodeASCII\0ISO-10646-Unicode-Latin1\0csUnicodeLatin1\0ISO-10646\0ISO-10646-"
      "J-1\0csUnicodeJapanese\0ISO-Unicode-IBM-1261\0csUnicodeIBM1261\0ISO-Unicode-IBM-1268\0csUnicodeIBM1268\0ISO-"
      "Unicode-IBM-1276\0csUnicodeIBM1276\0ISO-Unicode-IBM-1264\0csUnicodeIBM1264\0ISO-Unicode-IBM-"
      "1265\0csUnicodeIBM1265\0UNICODE-1-1\0csUnicode11\0SCSU\0csSCSU\0UTF-7\0csUTF7\0UTF-16BE\0csUTF16BE\0UTF-"
      "16LE\0csUTF16LE\0UTF-16\0csUTF16\0CESU-8\0csCESU8\0csCESU-8\0UTF-32\0csUTF32\0UTF-32BE\0csUTF32BE\0UTF-"
      "32LE\0csUTF32LE\0BOCU-1\0csBOCU1\0csBOCU-1\0UTF-7-IMAP\0csUTF7IMAP\0ISO-8859-1-Windows-3.0-Latin-"
      "1\0csWindows30Latin1\0ISO-8859-1-Windows-3.1-Latin-1\0csWindows31Latin1\0ISO-8859-2-Windows-Latin-"
      "2\0csWindows31Latin2\0ISO-8859-9-Windows-Latin-5\0csWindows31Latin5\0hp-roman8\0roman8\0r8\0csHPRoman8\0Adobe-"
      "Standard-Encoding\0csAdobeStandardEncoding\0Ventura-US\0csVenturaUS\0Ventura-"
      "International\0csVenturaInternational\0DEC-"
      "MCS\0dec\0csDECMCS\0IBM850\0cp850\0850\0csPC850Multilingual\0IBM852\0cp852\0852\0csPCp852\0IBM437\0cp437\0"
      "437\0csPC8CodePage437\0PC8-Danish-Norwegian\0csPC8DanishNorwegian\0IBM862\0cp862\0862\0csPC862LatinHebrew\0PC8-"
      "Turkish\0csPC8Turkish\0IBM-Symbols\0csIBMSymbols\0IBM-Thai\0csIBMThai\0HP-Legal\0csHPLegal\0HP-Pi-"
      "font\0csHPPiFont\0HP-Math8\0csHPMath8\0Adobe-Symbol-Encoding\0csHPPSMath\0HP-DeskTop\0csHPDesktop\0Ventura-"
      "Math\0csVenturaMath\0Microsoft-Publishing\0csMicrosoftPublishing\0Windows-"
      "31J\0csWindows31J\0GB2312\0csGB2312\0Big5\0csBig5\0macintosh\0mac\0csMacintosh\0IBM037\0cp037\0ebcdic-cp-"
      "us\0ebcdic-cp-ca\0ebcdic-cp-wt\0ebcdic-cp-nl\0csIBM037\0IBM038\0EBCDIC-"
      "INT\0cp038\0csIBM038\0IBM273\0CP273\0csIBM273\0IBM274\0EBCDIC-BE\0CP274\0csIBM274\0IBM275\0EBCDIC-"
      "BR\0cp275\0csIBM275\0IBM277\0EBCDIC-CP-DK\0EBCDIC-CP-NO\0csIBM277\0IBM278\0CP278\0ebcdic-cp-fi\0ebcdic-cp-"
      "se\0csIBM278\0IBM280\0CP280\0ebcdic-cp-it\0csIBM280\0IBM281\0EBCDIC-JP-"
      "E\0cp281\0csIBM281\0IBM284\0CP284\0ebcdic-cp-es\0csIBM284\0IBM285\0CP285\0ebcdic-cp-"
      "gb\0csIBM285\0IBM290\0cp290\0EBCDIC-JP-kana\0csIBM290\0IBM297\0cp297\0ebcdic-cp-"
      "fr\0csIBM297\0IBM420\0cp420\0ebcdic-cp-ar1\0csIBM420\0IBM423\0cp423\0ebcdic-cp-"
      "gr\0csIBM423\0IBM424\0cp424\0ebcdic-cp-he\0csIBM424\0IBM500\0CP500\0ebcdic-cp-be\0ebcdic-cp-"
      "ch\0csIBM500\0IBM851\0cp851\0851\0csIBM851\0IBM855\0cp855\0855\0csIBM855\0IBM857\0cp857\0857\0csIBM857\0IBM860\0"
      "cp860\0860\0csIBM860\0IBM861\0cp861\0861\0cp-"
      "is\0csIBM861\0IBM863\0cp863\0863\0csIBM863\0IBM864\0cp864\0csIBM864\0IBM865\0cp865\0865\0csIBM865\0IBM868\0CP868"
      "\0cp-ar\0csIBM868\0IBM869\0cp869\0869\0cp-gr\0csIBM869\0IBM870\0CP870\0ebcdic-cp-roece\0ebcdic-cp-"
      "yu\0csIBM870\0IBM871\0CP871\0ebcdic-cp-is\0csIBM871\0IBM880\0cp880\0EBCDIC-"
      "Cyrillic\0csIBM880\0IBM891\0cp891\0csIBM891\0IBM903\0cp903\0csIBM903\0IBM904\0cp904\0904\0csIBBM904\0IBM905\0CP9"
      "05\0ebcdic-cp-tr\0csIBM905\0IBM918\0CP918\0ebcdic-cp-ar2\0csIBM918\0IBM1026\0CP1026\0csIBM1026\0EBCDIC-AT-"
      "DE\0csIBMEBCDICATDE\0EBCDIC-AT-DE-A\0csEBCDICATDEA\0EBCDIC-CA-FR\0csEBCDICCAFR\0EBCDIC-DK-"
      "NO\0csEBCDICDKNO\0EBCDIC-DK-NO-A\0csEBCDICDKNOA\0EBCDIC-FI-SE\0csEBCDICFISE\0EBCDIC-FI-SE-"
      "A\0csEBCDICFISEA\0EBCDIC-FR\0csEBCDICFR\0EBCDIC-IT\0csEBCDICIT\0EBCDIC-PT\0csEBCDICPT\0EBCDIC-"
      "ES\0csEBCDICES\0EBCDIC-ES-A\0csEBCDICESA\0EBCDIC-ES-S\0csEBCDICESS\0EBCDIC-UK\0csEBCDICUK\0EBCDIC-"
      "US\0csEBCDICUS\0UNKNOWN-"
      "8BIT\0csUnknown8BiT\0MNEMONIC\0csMnemonic\0MNEM\0csMnem\0VISCII\0csVISCII\0VIQR\0csVIQR\0KOI8-R\0csKOI8R\0HZ-GB-"
      "2312\0IBM866\0cp866\0866\0csIBM866\0IBM775\0cp775\0csPC775Baltic\0KOI8-"
      "U\0csKOI8U\0IBM00858\0CCSID00858\0CP00858\0PC-Multilingual-850+"
      "euro\0csIBM00858\0IBM00924\0CCSID00924\0CP00924\0ebcdic-Latin9--"
      "euro\0csIBM00924\0IBM01140\0CCSID01140\0CP01140\0ebcdic-us-37+"
      "euro\0csIBM01140\0IBM01141\0CCSID01141\0CP01141\0ebcdic-de-273+"
      "euro\0csIBM01141\0IBM01142\0CCSID01142\0CP01142\0ebcdic-dk-277+euro\0ebcdic-no-277+"
      "euro\0csIBM01142\0IBM01143\0CCSID01143\0CP01143\0ebcdic-fi-278+euro\0ebcdic-se-278+"
      "euro\0csIBM01143\0IBM01144\0CCSID01144\0CP01144\0ebcdic-it-280+"
      "euro\0csIBM01144\0IBM01145\0CCSID01145\0CP01145\0ebcdic-es-284+"
      "euro\0csIBM01145\0IBM01146\0CCSID01146\0CP01146\0ebcdic-gb-285+"
      "euro\0csIBM01146\0IBM01147\0CCSID01147\0CP01147\0ebcdic-fr-297+"
      "euro\0csIBM01147\0IBM01148\0CCSID01148\0CP01148\0ebcdic-international-500+"
      "euro\0csIBM01148\0IBM01149\0CCSID01149\0CP01149\0ebcdic-is-871+euro\0csIBM01149\0Big5-"
      "HKSCS\0csBig5HKSCS\0IBM1047\0IBM-1047\0csIBM1047\0PTCP154\0csPTCP154\0PT154\0CP154\0Cyrillic-Asian\0Amiga-"
      "1251\0Ami1251\0Amiga1251\0Ami-1251\0csAmiga1251\0KOI7-"
      "switched\0csKOI7switched\0BRF\0csBRF\0TSCII\0csTSCII\0CP51932\0csCP51932\0windows-874\0cswindows874\0windows-"
      "1250\0cswindows1250\0windows-1251\0cswindows1251\0windows-1252\0cswindows1252\0windows-"
      "1253\0cswindows1253\0windows-1254\0cswindows1254\0windows-1255\0cswindows1255\0windows-"
      "1256\0cswindows1256\0windows-1257\0cswindows1257\0windows-1258\0cswindows1258\0TIS-620\0csTIS620\0ISO-8859-"
      "11\0CP50220\0csCP50220\0";

  struct __offset_table {
    constexpr static unsigned long long __num_aliases =
        std::count(__aliases_string, __aliases_string + sizeof(__aliases_string), '\0') + 1;
    unsigned short __table[__num_aliases];
  };

  static constexpr __offset_table __alias_offsets = [] {
    __offset_table __aliases{};
    __aliases.__table[0] = sizeof(__aliases_string) - 1;
    __aliases.__table[1] = sizeof(__aliases_string) - 1;
    __aliases.__table[2] = 0;

    unsigned long long __idx = 3;

    for (unsigned short __pos = 0; __pos < sizeof(__aliases_string) - 1 && __idx < __offset_table::__num_aliases;
         __pos++) {
      if (__aliases_string[__pos] == '\0') {
        __aliases.__table[__idx++] = __pos + 1;
      }
    }

    return __aliases;
  }();
};

template <>
struct hash<text_encoding> {
  [[nodiscard]] static size_t operator()(const text_encoding& __enc) noexcept {
    return std::hash<std::text_encoding::id>()(__enc.mib());
  }
};

template <>
inline constexpr bool ranges::enable_borrowed_range<text_encoding::aliases_view> = true;

_LIBCPP_END_NAMESPACE_STD

#  endif // _LIBCPP_STD_VER >= 26

#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)

#endif // _LIBCPP_TEXT_ENCODING
