Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:30

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 // WARNING, this entire header is generated by
0011 // utils/generate_width_estimation_table.py
0012 // DO NOT MODIFY!
0013 
0014 // UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
0015 //
0016 // See Terms of Use <https://www.unicode.org/copyright.html>
0017 // for definitions of Unicode Inc.'s Data Files and Software.
0018 //
0019 // NOTICE TO USER: Carefully read the following legal agreement.
0020 // BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
0021 // DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
0022 // YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
0023 // TERMS AND CONDITIONS OF THIS AGREEMENT.
0024 // IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
0025 // THE DATA FILES OR SOFTWARE.
0026 //
0027 // COPYRIGHT AND PERMISSION NOTICE
0028 //
0029 // Copyright (c) 1991-2022 Unicode, Inc. All rights reserved.
0030 // Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
0031 //
0032 // Permission is hereby granted, free of charge, to any person obtaining
0033 // a copy of the Unicode data files and any associated documentation
0034 // (the "Data Files") or Unicode software and any associated documentation
0035 // (the "Software") to deal in the Data Files or Software
0036 // without restriction, including without limitation the rights to use,
0037 // copy, modify, merge, publish, distribute, and/or sell copies of
0038 // the Data Files or Software, and to permit persons to whom the Data Files
0039 // or Software are furnished to do so, provided that either
0040 // (a) this copyright and permission notice appear with all copies
0041 // of the Data Files or Software, or
0042 // (b) this copyright and permission notice appear in associated
0043 // Documentation.
0044 //
0045 // THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
0046 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
0047 // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0048 // NONINFRINGEMENT OF THIRD PARTY RIGHTS.
0049 // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
0050 // NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
0051 // DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
0052 // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
0053 // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
0054 // PERFORMANCE OF THE DATA FILES OR SOFTWARE.
0055 //
0056 // Except as contained in this notice, the name of a copyright holder
0057 // shall not be used in advertising or otherwise to promote the sale,
0058 // use or other dealings in these Data Files or Software without prior
0059 // written authorization of the copyright holder.
0060 
0061 #ifndef _LIBCPP___CXX03___FORMAT_WIDTH_ESTIMATION_TABLE_H
0062 #define _LIBCPP___CXX03___FORMAT_WIDTH_ESTIMATION_TABLE_H
0063 
0064 #include <__cxx03/__algorithm/ranges_upper_bound.h>
0065 #include <__cxx03/__config>
0066 #include <__cxx03/cstddef>
0067 #include <__cxx03/cstdint>
0068 
0069 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0070 #  pragma GCC system_header
0071 #endif
0072 
0073 _LIBCPP_BEGIN_NAMESPACE_STD
0074 
0075 #if _LIBCPP_STD_VER >= 20
0076 
0077 namespace __width_estimation_table {
0078 
0079 /// The entries of the characters with an estimated width of 2.
0080 ///
0081 /// Contains the entries for [format.string.std]/12
0082 ///  -  Any code point with the East_Asian_Width="W" or East_Asian_Width="F"
0083 ///     Derived Extracted Property as described by UAX #44
0084 /// - U+4DC0 - U+4DFF (Yijing Hexagram Symbols)
0085 /// - U+1F300 - U+1F5FF (Miscellaneous Symbols and Pictographs)
0086 /// - U+1F900 - U+1F9FF (Supplemental Symbols and Pictographs)
0087 ///
0088 /// The data is generated from
0089 /// - https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt
0090 /// - The "overrides" in [format.string.std]/12
0091 ///
0092 /// The format of EastAsianWidth.txt is two fields separated by a semicolon.
0093 /// Field 0: Unicode code point value or range of code point values
0094 /// Field 1: East_Asian_Width property, consisting of one of the following values:
0095 ///         "A", "F", "H", "N", "Na", "W"
0096 ///  - All code points, assigned or unassigned, that are not listed
0097 ///      explicitly are given the value "N".
0098 ///  - The unassigned code points in the following blocks default to "W":
0099 ///         CJK Unified Ideographs Extension A: U+3400..U+4DBF
0100 ///         CJK Unified Ideographs:             U+4E00..U+9FFF
0101 ///         CJK Compatibility Ideographs:       U+F900..U+FAFF
0102 ///  - All undesignated code points in Planes 2 and 3, whether inside or
0103 ///      outside of allocated blocks, default to "W":
0104 ///         Plane 2:                            U+20000..U+2FFFD
0105 ///         Plane 3:                            U+30000..U+3FFFD
0106 ///
0107 /// The table is similar to the table
0108 ///  __extended_grapheme_custer_property_boundary::__entries
0109 /// which explains the details of these classes. The only difference is this
0110 /// table lacks a property, thus having more bits available for the size.
0111 ///
0112 /// The maximum code point that has an estimated width of 2 is U+3FFFD. This
0113 /// value can be encoded in 18 bits. Thus the upper 3 bits of the code point
0114 /// are always 0. These 3 bits are used to enlarge the offset range. This
0115 /// optimization reduces the table in Unicode 15 from 184 to 104 entries,
0116 /// saving 320 bytes.
0117 ///
0118 /// The data has 2 values:
0119 /// - bits [0, 13] The size of the range, allowing 16384 elements.
0120 /// - bits [14, 31] The lower bound code point of the range. The upper bound of
0121 ///   the range is lower bound + size.
0122 _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {
0123     0x0440005f /* 00001100 - 0000115f [   96] */, //
0124     0x08c68001 /* 0000231a - 0000231b [    2] */, //
0125     0x08ca4001 /* 00002329 - 0000232a [    2] */, //
0126     0x08fa4003 /* 000023e9 - 000023ec [    4] */, //
0127     0x08fc0000 /* 000023f0 - 000023f0 [    1] */, //
0128     0x08fcc000 /* 000023f3 - 000023f3 [    1] */, //
0129     0x097f4001 /* 000025fd - 000025fe [    2] */, //
0130     0x09850001 /* 00002614 - 00002615 [    2] */, //
0131     0x0992000b /* 00002648 - 00002653 [   12] */, //
0132     0x099fc000 /* 0000267f - 0000267f [    1] */, //
0133     0x09a4c000 /* 00002693 - 00002693 [    1] */, //
0134     0x09a84000 /* 000026a1 - 000026a1 [    1] */, //
0135     0x09aa8001 /* 000026aa - 000026ab [    2] */, //
0136     0x09af4001 /* 000026bd - 000026be [    2] */, //
0137     0x09b10001 /* 000026c4 - 000026c5 [    2] */, //
0138     0x09b38000 /* 000026ce - 000026ce [    1] */, //
0139     0x09b50000 /* 000026d4 - 000026d4 [    1] */, //
0140     0x09ba8000 /* 000026ea - 000026ea [    1] */, //
0141     0x09bc8001 /* 000026f2 - 000026f3 [    2] */, //
0142     0x09bd4000 /* 000026f5 - 000026f5 [    1] */, //
0143     0x09be8000 /* 000026fa - 000026fa [    1] */, //
0144     0x09bf4000 /* 000026fd - 000026fd [    1] */, //
0145     0x09c14000 /* 00002705 - 00002705 [    1] */, //
0146     0x09c28001 /* 0000270a - 0000270b [    2] */, //
0147     0x09ca0000 /* 00002728 - 00002728 [    1] */, //
0148     0x09d30000 /* 0000274c - 0000274c [    1] */, //
0149     0x09d38000 /* 0000274e - 0000274e [    1] */, //
0150     0x09d4c002 /* 00002753 - 00002755 [    3] */, //
0151     0x09d5c000 /* 00002757 - 00002757 [    1] */, //
0152     0x09e54002 /* 00002795 - 00002797 [    3] */, //
0153     0x09ec0000 /* 000027b0 - 000027b0 [    1] */, //
0154     0x09efc000 /* 000027bf - 000027bf [    1] */, //
0155     0x0ac6c001 /* 00002b1b - 00002b1c [    2] */, //
0156     0x0ad40000 /* 00002b50 - 00002b50 [    1] */, //
0157     0x0ad54000 /* 00002b55 - 00002b55 [    1] */, //
0158     0x0ba00019 /* 00002e80 - 00002e99 [   26] */, //
0159     0x0ba6c058 /* 00002e9b - 00002ef3 [   89] */, //
0160     0x0bc000d5 /* 00002f00 - 00002fd5 [  214] */, //
0161     0x0bfc004e /* 00002ff0 - 0000303e [   79] */, //
0162     0x0c104055 /* 00003041 - 00003096 [   86] */, //
0163     0x0c264066 /* 00003099 - 000030ff [  103] */, //
0164     0x0c41402a /* 00003105 - 0000312f [   43] */, //
0165     0x0c4c405d /* 00003131 - 0000318e [   94] */, //
0166     0x0c640053 /* 00003190 - 000031e3 [   84] */, //
0167     0x0c7bc02f /* 000031ef - 0000321e [   48] */, //
0168     0x0c880027 /* 00003220 - 00003247 [   40] */, //
0169     0x0c943fff /* 00003250 - 0000724f [16384] */, //
0170     0x1c94323c /* 00007250 - 0000a48c [12861] */, //
0171     0x29240036 /* 0000a490 - 0000a4c6 [   55] */, //
0172     0x2a58001c /* 0000a960 - 0000a97c [   29] */, //
0173     0x2b002ba3 /* 0000ac00 - 0000d7a3 [11172] */, //
0174     0x3e4001ff /* 0000f900 - 0000faff [  512] */, //
0175     0x3f840009 /* 0000fe10 - 0000fe19 [   10] */, //
0176     0x3f8c0022 /* 0000fe30 - 0000fe52 [   35] */, //
0177     0x3f950012 /* 0000fe54 - 0000fe66 [   19] */, //
0178     0x3f9a0003 /* 0000fe68 - 0000fe6b [    4] */, //
0179     0x3fc0405f /* 0000ff01 - 0000ff60 [   96] */, //
0180     0x3ff80006 /* 0000ffe0 - 0000ffe6 [    7] */, //
0181     0x5bf80004 /* 00016fe0 - 00016fe4 [    5] */, //
0182     0x5bfc0001 /* 00016ff0 - 00016ff1 [    2] */, //
0183     0x5c0017f7 /* 00017000 - 000187f7 [ 6136] */, //
0184     0x620004d5 /* 00018800 - 00018cd5 [ 1238] */, //
0185     0x63400008 /* 00018d00 - 00018d08 [    9] */, //
0186     0x6bfc0003 /* 0001aff0 - 0001aff3 [    4] */, //
0187     0x6bfd4006 /* 0001aff5 - 0001affb [    7] */, //
0188     0x6bff4001 /* 0001affd - 0001affe [    2] */, //
0189     0x6c000122 /* 0001b000 - 0001b122 [  291] */, //
0190     0x6c4c8000 /* 0001b132 - 0001b132 [    1] */, //
0191     0x6c540002 /* 0001b150 - 0001b152 [    3] */, //
0192     0x6c554000 /* 0001b155 - 0001b155 [    1] */, //
0193     0x6c590003 /* 0001b164 - 0001b167 [    4] */, //
0194     0x6c5c018b /* 0001b170 - 0001b2fb [  396] */, //
0195     0x7c010000 /* 0001f004 - 0001f004 [    1] */, //
0196     0x7c33c000 /* 0001f0cf - 0001f0cf [    1] */, //
0197     0x7c638000 /* 0001f18e - 0001f18e [    1] */, //
0198     0x7c644009 /* 0001f191 - 0001f19a [   10] */, //
0199     0x7c800002 /* 0001f200 - 0001f202 [    3] */, //
0200     0x7c84002b /* 0001f210 - 0001f23b [   44] */, //
0201     0x7c900008 /* 0001f240 - 0001f248 [    9] */, //
0202     0x7c940001 /* 0001f250 - 0001f251 [    2] */, //
0203     0x7c980005 /* 0001f260 - 0001f265 [    6] */, //
0204     0x7cc0034f /* 0001f300 - 0001f64f [  848] */, //
0205     0x7da00045 /* 0001f680 - 0001f6c5 [   70] */, //
0206     0x7db30000 /* 0001f6cc - 0001f6cc [    1] */, //
0207     0x7db40002 /* 0001f6d0 - 0001f6d2 [    3] */, //
0208     0x7db54002 /* 0001f6d5 - 0001f6d7 [    3] */, //
0209     0x7db70003 /* 0001f6dc - 0001f6df [    4] */, //
0210     0x7dbac001 /* 0001f6eb - 0001f6ec [    2] */, //
0211     0x7dbd0008 /* 0001f6f4 - 0001f6fc [    9] */, //
0212     0x7df8000b /* 0001f7e0 - 0001f7eb [   12] */, //
0213     0x7dfc0000 /* 0001f7f0 - 0001f7f0 [    1] */, //
0214     0x7e4000ff /* 0001f900 - 0001f9ff [  256] */, //
0215     0x7e9c000c /* 0001fa70 - 0001fa7c [   13] */, //
0216     0x7ea00008 /* 0001fa80 - 0001fa88 [    9] */, //
0217     0x7ea4002d /* 0001fa90 - 0001fabd [   46] */, //
0218     0x7eafc006 /* 0001fabf - 0001fac5 [    7] */, //
0219     0x7eb3800d /* 0001face - 0001fadb [   14] */, //
0220     0x7eb80008 /* 0001fae0 - 0001fae8 [    9] */, //
0221     0x7ebc0008 /* 0001faf0 - 0001faf8 [    9] */, //
0222     0x80003fff /* 00020000 - 00023fff [16384] */, //
0223     0x90003fff /* 00024000 - 00027fff [16384] */, //
0224     0xa0003fff /* 00028000 - 0002bfff [16384] */, //
0225     0xb0003ffd /* 0002c000 - 0002fffd [16382] */, //
0226     0xc0003fff /* 00030000 - 00033fff [16384] */, //
0227     0xd0003fff /* 00034000 - 00037fff [16384] */, //
0228     0xe0003fff /* 00038000 - 0003bfff [16384] */, //
0229     0xf0003ffd /* 0003c000 - 0003fffd [16382] */};
0230 
0231 /// The upper bound entry of EastAsianWidth.txt.
0232 ///
0233 /// Values greater than this value may have more than 18 significant bits.
0234 /// They always have a width of 1. This property makes it possible to store
0235 /// the table in its compact form.
0236 inline constexpr uint32_t __table_upper_bound = 0x0003fffd;
0237 
0238 /// Returns the estimated width of a Unicode code point.
0239 ///
0240 /// \\pre The code point is a valid Unicode code point.
0241 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int __estimated_width(const char32_t __code_point) noexcept {
0242   // Since __table_upper_bound contains the unshifted range do the
0243   // comparison without shifting.
0244   if (__code_point > __table_upper_bound) [[unlikely]]
0245     return 1;
0246 
0247   // When the code-point is less than the first element in the table
0248   // the lookup is quite expensive. Since quite some scripts are in
0249   // that range, it makes sense to validate that first.
0250   // The std_format_spec_string_unicode benchmark gives a measurable
0251   // improvement.
0252   if (__code_point < (__entries[0] >> 14))
0253     return 1;
0254 
0255   ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 14) | 0x3fffu) - __entries;
0256   if (__i == 0)
0257     return 1;
0258 
0259   --__i;
0260   uint32_t __upper_bound = (__entries[__i] >> 14) + (__entries[__i] & 0x3fffu);
0261   return 1 + (__code_point <= __upper_bound);
0262 }
0263 
0264 } // namespace __width_estimation_table
0265 
0266 #endif //_LIBCPP_STD_VER >= 20
0267 
0268 _LIBCPP_END_NAMESPACE_STD
0269 
0270 #endif // _LIBCPP___CXX03___FORMAT_WIDTH_ESTIMATION_TABLE_H