diff --git a/src/fallback.cpp b/src/fallback.cpp index 1225c0a3b..37c2aa8dc 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -288,66 +288,30 @@ int fish_wcwidth(wchar_t wc) { return wcwidth(wc); } int fish_wcswidth(const wchar_t *str, size_t n) { return wcswidth(str, n); } #else -#include "wcwidth9/wcwidth9.h" - -// This is the sort listed of inclusive ranges of characters whose width was 1 in Unicode 8, but was -// changed to width 2 in Unicode 9. Note that no characters became narrower from Unicode 8 to 9. -static bool is_width_2_in_Uni9_but_1_in_Uni8(wchar_t c) { - const struct pair_t { - int lo; - int hi; - } pairs[] = {{0x0231A, 0x0231B}, {0x023E9, 0x023EC}, {0x023F0, 0x023F0}, {0x023F3, 0x023F3}, - {0x025FD, 0x025FE}, {0x02614, 0x02615}, {0x02648, 0x02653}, {0x0267F, 0x0267F}, - {0x02693, 0x02693}, {0x026A1, 0x026A1}, {0x026AA, 0x026AB}, {0x026BD, 0x026BE}, - {0x026C4, 0x026C5}, {0x026CE, 0x026CE}, {0x026D4, 0x026D4}, {0x026EA, 0x026EA}, - {0x026F2, 0x026F3}, {0x026F5, 0x026F5}, {0x026FA, 0x026FA}, {0x026FD, 0x026FD}, - {0x02705, 0x02705}, {0x0270A, 0x0270B}, {0x02728, 0x02728}, {0x0274C, 0x0274C}, - {0x0274E, 0x0274E}, {0x02753, 0x02755}, {0x02757, 0x02757}, {0x02795, 0x02797}, - {0x027B0, 0x027B0}, {0x027BF, 0x027BF}, {0x02B1B, 0x02B1C}, {0x02B50, 0x02B50}, - {0x02B55, 0x02B55}, {0x16FE0, 0x16FE0}, {0x17000, 0x187EC}, {0x18800, 0x18AF2}, - {0x1F004, 0x1F004}, {0x1F0CF, 0x1F0CF}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A}, - {0x1F23B, 0x1F23B}, {0x1F300, 0x1F320}, {0x1F32D, 0x1F335}, {0x1F337, 0x1F37C}, - {0x1F37E, 0x1F393}, {0x1F3A0, 0x1F3CA}, {0x1F3CF, 0x1F3D3}, {0x1F3E0, 0x1F3F0}, - {0x1F3F4, 0x1F3F4}, {0x1F3F8, 0x1F43E}, {0x1F440, 0x1F440}, {0x1F442, 0x1F4FC}, - {0x1F4FF, 0x1F53D}, {0x1F54B, 0x1F54E}, {0x1F550, 0x1F567}, {0x1F57A, 0x1F57A}, - {0x1F595, 0x1F596}, {0x1F5A4, 0x1F5A4}, {0x1F5FB, 0x1F64F}, {0x1F680, 0x1F6C5}, - {0x1F6CC, 0x1F6CC}, {0x1F6D0, 0x1F6D2}, {0x1F6EB, 0x1F6EC}, {0x1F6F4, 0x1F6F6}, - {0x1F910, 0x1F91E}, {0x1F920, 0x1F927}, {0x1F930, 0x1F930}, {0x1F933, 0x1F93E}, - {0x1F940, 0x1F94B}, {0x1F950, 0x1F95E}, {0x1F980, 0x1F991}, {0x1F9C0, 0x1F9C0}}; - auto where = std::lower_bound(std::begin(pairs), std::end(pairs), c, - [](pair_t p, wchar_t c) { return p.hi < c; }); - assert((where == std::end(pairs) || where->hi >= c) && "unexpected binary search result"); - return where != std::end(pairs) && where->lo <= c; -} - -// Return whether wc is a variation selector, which wcwidth() is likely to mishandle (#2652). -static bool is_variation_selector(wchar_t wc) { - return (0xFE00 <= wc && wc <= 0xFE0F) // variation selectors - || (0xE0100 <= wc && wc <= 0xE01EF) // variation selector supplement - || (0x180B <= wc && wc <= 0x180D); // Mongolian variation selectors -} - -// Possible negative return values from wcwidth9() -enum { width_non_printable = -1, width_ambiguous = -2, width_private_use = -3 }; +#include "widecharwidth/widechar_width.h" int fish_wcwidth(wchar_t wc) { - // Check for certain characters whose width is terminal emulator dependent. - if (is_width_2_in_Uni9_but_1_in_Uni8(wc)) return fish_get_emoji_width(wc); + // Check for VS16 which selects emoji presentation. This "promotes" a character like U+2764 + // (width 1) to an emoji (probably width 2). So treat it as width 1 so the sums work. See #2652. + const int variation_selector_16 = 0xFE0F; + if (wc == variation_selector_16) return 1; - // Check for variation selectors which system wcwidth mishandles (see #2652). - if (is_variation_selector(wc)) return -1; - - int w9_width = wcwidth9(wc); - if (w9_width >= 0) return w9_width; - - // Fall back to system wcwidth(). - int sys_width = wcwidth(wc); - if (sys_width >= 0) return sys_width; - - // Treat ambiguous and private use widths as 1. - if (w9_width == width_ambiguous || w9_width == width_private_use) return 1; - - return -1; + int width = widechar_wcwidth(wc); + switch (width) { + case widechar_nonprint: + case widechar_combining: + case widechar_unassigned: + // Fall back to system wcwidth in this case. + return wcwidth(wc); + case widechar_ambiguous: + case widechar_private_use: + return 1; + case widechar_widened_in_9: + return fish_get_emoji_width(wc); + default: + assert(width > 0 && "Unexpectedly nonpositive width"); + return width; + } } int fish_wcswidth(const wchar_t *str, size_t n) { diff --git a/src/wcwidth9/LICENSE b/src/wcwidth9/LICENSE deleted file mode 100644 index a9ed962a3..000000000 --- a/src/wcwidth9/LICENSE +++ /dev/null @@ -1,289 +0,0 @@ -The code for wcwidth9 came primarily from neovim (which may in turn, also have -come from vim). - -Any original code is copyright Joshua Rubin and licensed under the Apache 2.0 -license or (only if required by the terms of the vim license) vim license. - -The license for neovim follows: - -Copyright Neovim contributors. All rights reserved. - -Neovim is licensed under the terms of the Apache 2.0 license, except for -parts of Neovim that were contributed under the Vim license (see below). - -Neovim's license follows: - -==== - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -==== - -The above license applies to all parts of Neovim except (1) parts that were -contributed under the Vim license and (2) externally maintained libraries. - -The externally maintained libraries used by Neovim are: - - - Klib: a Generic Library in C. MIT/X11 license. - - libuv. Copyright Joyent, Inc. and other Node contributors. Node.js license. - - LuaJIT: a Just-In-Time Compiler for Lua. Copyright Mike Pall. MIT license. - -==== - -Any parts of Neovim that were contributed under the Vim license are licensed -under the Vim license unless the copyright holder gave permission to license -those contributions under the Apache 2.0 license. - -The Vim license follows: - -VIM LICENSE - -I) There are no restrictions on distributing unmodified copies of Vim except - that they must include this license text. You can also distribute - unmodified parts of Vim, likewise unrestricted except that they must - include this license text. You are also allowed to include executables - that you made from the unmodified Vim sources, plus your own usage - examples and Vim scripts. - -II) It is allowed to distribute a modified (or extended) version of Vim, - including executables and/or source code, when the following four - conditions are met: - 1) This license text must be included unmodified. - 2) The modified Vim must be distributed in one of the following five ways: - a) If you make changes to Vim yourself, you must clearly describe in - the distribution how to contact you. When the maintainer asks you - (in any way) for a copy of the modified Vim you distributed, you - must make your changes, including source code, available to the - maintainer without fee. The maintainer reserves the right to - include your changes in the official version of Vim. What the - maintainer will do with your changes and under what license they - will be distributed is negotiable. If there has been no negotiation - then this license, or a later version, also applies to your changes. - The current maintainer is Bram Moolenaar . If this - changes it will be announced in appropriate places (most likely - vim.sf.net, www.vim.org and/or comp.editors). When it is completely - impossible to contact the maintainer, the obligation to send him - your changes ceases. Once the maintainer has confirmed that he has - received your changes they will not have to be sent again. - b) If you have received a modified Vim that was distributed as - mentioned under a) you are allowed to further distribute it - unmodified, as mentioned at I). If you make additional changes the - text under a) applies to those changes. - c) Provide all the changes, including source code, with every copy of - the modified Vim you distribute. This may be done in the form of a - context diff. You can choose what license to use for new code you - add. The changes and their license must not restrict others from - making their own changes to the official version of Vim. - d) When you have a modified Vim which includes changes as mentioned - under c), you can distribute it without the source code for the - changes if the following three conditions are met: - - The license that applies to the changes permits you to distribute - the changes to the Vim maintainer without fee or restriction, and - permits the Vim maintainer to include the changes in the official - version of Vim without fee or restriction. - - You keep the changes for at least three years after last - distributing the corresponding modified Vim. When the maintainer - or someone who you distributed the modified Vim to asks you (in - any way) for the changes within this period, you must make them - available to him. - - You clearly describe in the distribution how to contact you. This - contact information must remain valid for at least three years - after last distributing the corresponding modified Vim, or as long - as possible. - e) When the GNU General Public License (GPL) applies to the changes, - you can distribute the modified Vim under the GNU GPL version 2 or - any later version. - 3) A message must be added, at least in the output of the ":version" - command and in the intro screen, such that the user of the modified Vim - is able to see that it was modified. When distributing as mentioned - under 2)e) adding the message is only required for as far as this does - not conflict with the license used for the changes. - 4) The contact information as required under 2)a) and 2)d) must not be - removed or changed, except that the person himself can make - corrections. - -III) If you distribute a modified version of Vim, you are encouraged to use - the Vim license for your changes and make them available to the - maintainer, including the source code. The preferred way to do this is - by e-mail or by uploading the files to a server and e-mailing the URL. - If the number of changes is small (e.g., a modified Makefile) e-mailing a - context diff will do. The e-mail address to be used is - - -IV) It is not allowed to remove this license from the distribution of the Vim - sources, parts of it or from a modified version. You may use this - license for previous Vim releases instead of the license that they came - with, at your option. - diff --git a/src/wcwidth9/wcwidth9.h b/src/wcwidth9/wcwidth9.h deleted file mode 100644 index d69f9b7fd..000000000 --- a/src/wcwidth9/wcwidth9.h +++ /dev/null @@ -1,405 +0,0 @@ -#ifndef WCWIDTH9_H -#define WCWIDTH9_H - -#include -#include - -struct wcwidth9_interval { - long first; - long last; -}; - -static const struct wcwidth9_interval wcwidth9_private[] = { - {0x00e000, 0x00f8ff}, {0x0f0000, 0x0ffffd}, {0x100000, 0x10fffd}, -}; - -static const struct wcwidth9_interval wcwidth9_nonprint[] = { - {0x0000, 0x001f}, {0x007f, 0x009f}, {0x00ad, 0x00ad}, {0x070f, 0x070f}, {0x180b, 0x180e}, - {0x200b, 0x200f}, {0x2028, 0x2029}, {0x202a, 0x202e}, {0x206a, 0x206f}, {0xd800, 0xdfff}, - {0xfeff, 0xfeff}, {0xfff9, 0xfffb}, {0xfffe, 0xffff}, -}; - -static const struct wcwidth9_interval wcwidth9_combining[] = { - {0x0300, 0x036f}, {0x0483, 0x0489}, {0x0591, 0x05bd}, {0x05bf, 0x05bf}, - {0x05c1, 0x05c2}, {0x05c4, 0x05c5}, {0x05c7, 0x05c7}, {0x0610, 0x061a}, - {0x064b, 0x065f}, {0x0670, 0x0670}, {0x06d6, 0x06dc}, {0x06df, 0x06e4}, - {0x06e7, 0x06e8}, {0x06ea, 0x06ed}, {0x0711, 0x0711}, {0x0730, 0x074a}, - {0x07a6, 0x07b0}, {0x07eb, 0x07f3}, {0x0816, 0x0819}, {0x081b, 0x0823}, - {0x0825, 0x0827}, {0x0829, 0x082d}, {0x0859, 0x085b}, {0x08d4, 0x08e1}, - {0x08e3, 0x0903}, {0x093a, 0x093c}, {0x093e, 0x094f}, {0x0951, 0x0957}, - {0x0962, 0x0963}, {0x0981, 0x0983}, {0x09bc, 0x09bc}, {0x09be, 0x09c4}, - {0x09c7, 0x09c8}, {0x09cb, 0x09cd}, {0x09d7, 0x09d7}, {0x09e2, 0x09e3}, - {0x0a01, 0x0a03}, {0x0a3c, 0x0a3c}, {0x0a3e, 0x0a42}, {0x0a47, 0x0a48}, - {0x0a4b, 0x0a4d}, {0x0a51, 0x0a51}, {0x0a70, 0x0a71}, {0x0a75, 0x0a75}, - {0x0a81, 0x0a83}, {0x0abc, 0x0abc}, {0x0abe, 0x0ac5}, {0x0ac7, 0x0ac9}, - {0x0acb, 0x0acd}, {0x0ae2, 0x0ae3}, {0x0b01, 0x0b03}, {0x0b3c, 0x0b3c}, - {0x0b3e, 0x0b44}, {0x0b47, 0x0b48}, {0x0b4b, 0x0b4d}, {0x0b56, 0x0b57}, - {0x0b62, 0x0b63}, {0x0b82, 0x0b82}, {0x0bbe, 0x0bc2}, {0x0bc6, 0x0bc8}, - {0x0bca, 0x0bcd}, {0x0bd7, 0x0bd7}, {0x0c00, 0x0c03}, {0x0c3e, 0x0c44}, - {0x0c46, 0x0c48}, {0x0c4a, 0x0c4d}, {0x0c55, 0x0c56}, {0x0c62, 0x0c63}, - {0x0c81, 0x0c83}, {0x0cbc, 0x0cbc}, {0x0cbe, 0x0cc4}, {0x0cc6, 0x0cc8}, - {0x0cca, 0x0ccd}, {0x0cd5, 0x0cd6}, {0x0ce2, 0x0ce3}, {0x0d01, 0x0d03}, - {0x0d3e, 0x0d44}, {0x0d46, 0x0d48}, {0x0d4a, 0x0d4d}, {0x0d57, 0x0d57}, - {0x0d62, 0x0d63}, {0x0d82, 0x0d83}, {0x0dca, 0x0dca}, {0x0dcf, 0x0dd4}, - {0x0dd6, 0x0dd6}, {0x0dd8, 0x0ddf}, {0x0df2, 0x0df3}, {0x0e31, 0x0e31}, - {0x0e34, 0x0e3a}, {0x0e47, 0x0e4e}, {0x0eb1, 0x0eb1}, {0x0eb4, 0x0eb9}, - {0x0ebb, 0x0ebc}, {0x0ec8, 0x0ecd}, {0x0f18, 0x0f19}, {0x0f35, 0x0f35}, - {0x0f37, 0x0f37}, {0x0f39, 0x0f39}, {0x0f3e, 0x0f3f}, {0x0f71, 0x0f84}, - {0x0f86, 0x0f87}, {0x0f8d, 0x0f97}, {0x0f99, 0x0fbc}, {0x0fc6, 0x0fc6}, - {0x102b, 0x103e}, {0x1056, 0x1059}, {0x105e, 0x1060}, {0x1062, 0x1064}, - {0x1067, 0x106d}, {0x1071, 0x1074}, {0x1082, 0x108d}, {0x108f, 0x108f}, - {0x109a, 0x109d}, {0x135d, 0x135f}, {0x1712, 0x1714}, {0x1732, 0x1734}, - {0x1752, 0x1753}, {0x1772, 0x1773}, {0x17b4, 0x17d3}, {0x17dd, 0x17dd}, - {0x180b, 0x180d}, {0x1885, 0x1886}, {0x18a9, 0x18a9}, {0x1920, 0x192b}, - {0x1930, 0x193b}, {0x1a17, 0x1a1b}, {0x1a55, 0x1a5e}, {0x1a60, 0x1a7c}, - {0x1a7f, 0x1a7f}, {0x1ab0, 0x1abe}, {0x1b00, 0x1b04}, {0x1b34, 0x1b44}, - {0x1b6b, 0x1b73}, {0x1b80, 0x1b82}, {0x1ba1, 0x1bad}, {0x1be6, 0x1bf3}, - {0x1c24, 0x1c37}, {0x1cd0, 0x1cd2}, {0x1cd4, 0x1ce8}, {0x1ced, 0x1ced}, - {0x1cf2, 0x1cf4}, {0x1cf8, 0x1cf9}, {0x1dc0, 0x1df5}, {0x1dfb, 0x1dff}, - {0x20d0, 0x20f0}, {0x2cef, 0x2cf1}, {0x2d7f, 0x2d7f}, {0x2de0, 0x2dff}, - {0x302a, 0x302f}, {0x3099, 0x309a}, {0xa66f, 0xa672}, {0xa674, 0xa67d}, - {0xa69e, 0xa69f}, {0xa6f0, 0xa6f1}, {0xa802, 0xa802}, {0xa806, 0xa806}, - {0xa80b, 0xa80b}, {0xa823, 0xa827}, {0xa880, 0xa881}, {0xa8b4, 0xa8c5}, - {0xa8e0, 0xa8f1}, {0xa926, 0xa92d}, {0xa947, 0xa953}, {0xa980, 0xa983}, - {0xa9b3, 0xa9c0}, {0xa9e5, 0xa9e5}, {0xaa29, 0xaa36}, {0xaa43, 0xaa43}, - {0xaa4c, 0xaa4d}, {0xaa7b, 0xaa7d}, {0xaab0, 0xaab0}, {0xaab2, 0xaab4}, - {0xaab7, 0xaab8}, {0xaabe, 0xaabf}, {0xaac1, 0xaac1}, {0xaaeb, 0xaaef}, - {0xaaf5, 0xaaf6}, {0xabe3, 0xabea}, {0xabec, 0xabed}, {0xfb1e, 0xfb1e}, - {0xfe00, 0xfe0f}, {0xfe20, 0xfe2f}, {0x101fd, 0x101fd}, {0x102e0, 0x102e0}, - {0x10376, 0x1037a}, {0x10a01, 0x10a03}, {0x10a05, 0x10a06}, {0x10a0c, 0x10a0f}, - {0x10a38, 0x10a3a}, {0x10a3f, 0x10a3f}, {0x10ae5, 0x10ae6}, {0x11000, 0x11002}, - {0x11038, 0x11046}, {0x1107f, 0x11082}, {0x110b0, 0x110ba}, {0x11100, 0x11102}, - {0x11127, 0x11134}, {0x11173, 0x11173}, {0x11180, 0x11182}, {0x111b3, 0x111c0}, - {0x111ca, 0x111cc}, {0x1122c, 0x11237}, {0x1123e, 0x1123e}, {0x112df, 0x112ea}, - {0x11300, 0x11303}, {0x1133c, 0x1133c}, {0x1133e, 0x11344}, {0x11347, 0x11348}, - {0x1134b, 0x1134d}, {0x11357, 0x11357}, {0x11362, 0x11363}, {0x11366, 0x1136c}, - {0x11370, 0x11374}, {0x11435, 0x11446}, {0x114b0, 0x114c3}, {0x115af, 0x115b5}, - {0x115b8, 0x115c0}, {0x115dc, 0x115dd}, {0x11630, 0x11640}, {0x116ab, 0x116b7}, - {0x1171d, 0x1172b}, {0x11c2f, 0x11c36}, {0x11c38, 0x11c3f}, {0x11c92, 0x11ca7}, - {0x11ca9, 0x11cb6}, {0x16af0, 0x16af4}, {0x16b30, 0x16b36}, {0x16f51, 0x16f7e}, - {0x16f8f, 0x16f92}, {0x1bc9d, 0x1bc9e}, {0x1d165, 0x1d169}, {0x1d16d, 0x1d172}, - {0x1d17b, 0x1d182}, {0x1d185, 0x1d18b}, {0x1d1aa, 0x1d1ad}, {0x1d242, 0x1d244}, - {0x1da00, 0x1da36}, {0x1da3b, 0x1da6c}, {0x1da75, 0x1da75}, {0x1da84, 0x1da84}, - {0x1da9b, 0x1da9f}, {0x1daa1, 0x1daaf}, {0x1e000, 0x1e006}, {0x1e008, 0x1e018}, - {0x1e01b, 0x1e021}, {0x1e023, 0x1e024}, {0x1e026, 0x1e02a}, {0x1e8d0, 0x1e8d6}, - {0x1e944, 0x1e94a}, {0xe0100, 0xe01ef}, -}; - -static const struct wcwidth9_interval wcwidth9_doublewidth[] = { - {0x1100, 0x115f}, {0x231a, 0x231b}, {0x2329, 0x232a}, {0x23e9, 0x23ec}, - {0x23f0, 0x23f0}, {0x23f3, 0x23f3}, {0x25fd, 0x25fe}, {0x2614, 0x2615}, - {0x2648, 0x2653}, {0x267f, 0x267f}, {0x2693, 0x2693}, {0x26a1, 0x26a1}, - {0x26aa, 0x26ab}, {0x26bd, 0x26be}, {0x26c4, 0x26c5}, {0x26ce, 0x26ce}, - {0x26d4, 0x26d4}, {0x26ea, 0x26ea}, {0x26f2, 0x26f3}, {0x26f5, 0x26f5}, - {0x26fa, 0x26fa}, {0x26fd, 0x26fd}, {0x2705, 0x2705}, {0x270a, 0x270b}, - {0x2728, 0x2728}, {0x274c, 0x274c}, {0x274e, 0x274e}, {0x2753, 0x2755}, - {0x2757, 0x2757}, {0x2795, 0x2797}, {0x27b0, 0x27b0}, {0x27bf, 0x27bf}, - {0x2b1b, 0x2b1c}, {0x2b50, 0x2b50}, {0x2b55, 0x2b55}, {0x2e80, 0x2e99}, - {0x2e9b, 0x2ef3}, {0x2f00, 0x2fd5}, {0x2ff0, 0x2ffb}, {0x3000, 0x303e}, - {0x3041, 0x3096}, {0x3099, 0x30ff}, {0x3105, 0x312d}, {0x3131, 0x318e}, - {0x3190, 0x31ba}, {0x31c0, 0x31e3}, {0x31f0, 0x321e}, {0x3220, 0x3247}, - {0x3250, 0x32fe}, {0x3300, 0x4dbf}, {0x4e00, 0xa48c}, {0xa490, 0xa4c6}, - {0xa960, 0xa97c}, {0xac00, 0xd7a3}, {0xf900, 0xfaff}, {0xfe10, 0xfe19}, - {0xfe30, 0xfe52}, {0xfe54, 0xfe66}, {0xfe68, 0xfe6b}, {0xff01, 0xff60}, - {0xffe0, 0xffe6}, {0x16fe0, 0x16fe0}, {0x17000, 0x187ec}, {0x18800, 0x18af2}, - {0x1b000, 0x1b001}, {0x1f004, 0x1f004}, {0x1f0cf, 0x1f0cf}, {0x1f18e, 0x1f18e}, - {0x1f191, 0x1f19a}, {0x1f200, 0x1f202}, {0x1f210, 0x1f23b}, {0x1f240, 0x1f248}, - {0x1f250, 0x1f251}, {0x1f300, 0x1f320}, {0x1f32d, 0x1f335}, {0x1f337, 0x1f37c}, - {0x1f37e, 0x1f393}, {0x1f3a0, 0x1f3ca}, {0x1f3cf, 0x1f3d3}, {0x1f3e0, 0x1f3f0}, - {0x1f3f4, 0x1f3f4}, {0x1f3f8, 0x1f43e}, {0x1f440, 0x1f440}, {0x1f442, 0x1f4fc}, - {0x1f4ff, 0x1f53d}, {0x1f54b, 0x1f54e}, {0x1f550, 0x1f567}, {0x1f57a, 0x1f57a}, - {0x1f595, 0x1f596}, {0x1f5a4, 0x1f5a4}, {0x1f5fb, 0x1f64f}, {0x1f680, 0x1f6c5}, - {0x1f6cc, 0x1f6cc}, {0x1f6d0, 0x1f6d2}, {0x1f6eb, 0x1f6ec}, {0x1f6f4, 0x1f6f6}, - {0x1f910, 0x1f91e}, {0x1f920, 0x1f927}, {0x1f930, 0x1f930}, {0x1f933, 0x1f93e}, - {0x1f940, 0x1f94b}, {0x1f950, 0x1f95e}, {0x1f980, 0x1f991}, {0x1f9c0, 0x1f9c0}, - {0x20000, 0x2fffd}, {0x30000, 0x3fffd}, -}; - -static const struct wcwidth9_interval wcwidth9_ambiguous[] = { - {0x00a1, 0x00a1}, {0x00a4, 0x00a4}, {0x00a7, 0x00a8}, {0x00aa, 0x00aa}, - {0x00ad, 0x00ae}, {0x00b0, 0x00b4}, {0x00b6, 0x00ba}, {0x00bc, 0x00bf}, - {0x00c6, 0x00c6}, {0x00d0, 0x00d0}, {0x00d7, 0x00d8}, {0x00de, 0x00e1}, - {0x00e6, 0x00e6}, {0x00e8, 0x00ea}, {0x00ec, 0x00ed}, {0x00f0, 0x00f0}, - {0x00f2, 0x00f3}, {0x00f7, 0x00fa}, {0x00fc, 0x00fc}, {0x00fe, 0x00fe}, - {0x0101, 0x0101}, {0x0111, 0x0111}, {0x0113, 0x0113}, {0x011b, 0x011b}, - {0x0126, 0x0127}, {0x012b, 0x012b}, {0x0131, 0x0133}, {0x0138, 0x0138}, - {0x013f, 0x0142}, {0x0144, 0x0144}, {0x0148, 0x014b}, {0x014d, 0x014d}, - {0x0152, 0x0153}, {0x0166, 0x0167}, {0x016b, 0x016b}, {0x01ce, 0x01ce}, - {0x01d0, 0x01d0}, {0x01d2, 0x01d2}, {0x01d4, 0x01d4}, {0x01d6, 0x01d6}, - {0x01d8, 0x01d8}, {0x01da, 0x01da}, {0x01dc, 0x01dc}, {0x0251, 0x0251}, - {0x0261, 0x0261}, {0x02c4, 0x02c4}, {0x02c7, 0x02c7}, {0x02c9, 0x02cb}, - {0x02cd, 0x02cd}, {0x02d0, 0x02d0}, {0x02d8, 0x02db}, {0x02dd, 0x02dd}, - {0x02df, 0x02df}, {0x0300, 0x036f}, {0x0391, 0x03a1}, {0x03a3, 0x03a9}, - {0x03b1, 0x03c1}, {0x03c3, 0x03c9}, {0x0401, 0x0401}, {0x0410, 0x044f}, - {0x0451, 0x0451}, {0x2010, 0x2010}, {0x2013, 0x2016}, {0x2018, 0x2019}, - {0x201c, 0x201d}, {0x2020, 0x2022}, {0x2024, 0x2027}, {0x2030, 0x2030}, - {0x2032, 0x2033}, {0x2035, 0x2035}, {0x203b, 0x203b}, {0x203e, 0x203e}, - {0x2074, 0x2074}, {0x207f, 0x207f}, {0x2081, 0x2084}, {0x20ac, 0x20ac}, - {0x2103, 0x2103}, {0x2105, 0x2105}, {0x2109, 0x2109}, {0x2113, 0x2113}, - {0x2116, 0x2116}, {0x2121, 0x2122}, {0x2126, 0x2126}, {0x212b, 0x212b}, - {0x2153, 0x2154}, {0x215b, 0x215e}, {0x2160, 0x216b}, {0x2170, 0x2179}, - {0x2189, 0x2189}, {0x2190, 0x2199}, {0x21b8, 0x21b9}, {0x21d2, 0x21d2}, - {0x21d4, 0x21d4}, {0x21e7, 0x21e7}, {0x2200, 0x2200}, {0x2202, 0x2203}, - {0x2207, 0x2208}, {0x220b, 0x220b}, {0x220f, 0x220f}, {0x2211, 0x2211}, - {0x2215, 0x2215}, {0x221a, 0x221a}, {0x221d, 0x2220}, {0x2223, 0x2223}, - {0x2225, 0x2225}, {0x2227, 0x222c}, {0x222e, 0x222e}, {0x2234, 0x2237}, - {0x223c, 0x223d}, {0x2248, 0x2248}, {0x224c, 0x224c}, {0x2252, 0x2252}, - {0x2260, 0x2261}, {0x2264, 0x2267}, {0x226a, 0x226b}, {0x226e, 0x226f}, - {0x2282, 0x2283}, {0x2286, 0x2287}, {0x2295, 0x2295}, {0x2299, 0x2299}, - {0x22a5, 0x22a5}, {0x22bf, 0x22bf}, {0x2312, 0x2312}, {0x2460, 0x24e9}, - {0x24eb, 0x254b}, {0x2550, 0x2573}, {0x2580, 0x258f}, {0x2592, 0x2595}, - {0x25a0, 0x25a1}, {0x25a3, 0x25a9}, {0x25b2, 0x25b3}, {0x25b6, 0x25b7}, - {0x25bc, 0x25bd}, {0x25c0, 0x25c1}, {0x25c6, 0x25c8}, {0x25cb, 0x25cb}, - {0x25ce, 0x25d1}, {0x25e2, 0x25e5}, {0x25ef, 0x25ef}, {0x2605, 0x2606}, - {0x2609, 0x2609}, {0x260e, 0x260f}, {0x261c, 0x261c}, {0x261e, 0x261e}, - {0x2640, 0x2640}, {0x2642, 0x2642}, {0x2660, 0x2661}, {0x2663, 0x2665}, - {0x2667, 0x266a}, {0x266c, 0x266d}, {0x266f, 0x266f}, {0x269e, 0x269f}, - {0x26bf, 0x26bf}, {0x26c6, 0x26cd}, {0x26cf, 0x26d3}, {0x26d5, 0x26e1}, - {0x26e3, 0x26e3}, {0x26e8, 0x26e9}, {0x26eb, 0x26f1}, {0x26f4, 0x26f4}, - {0x26f6, 0x26f9}, {0x26fb, 0x26fc}, {0x26fe, 0x26ff}, {0x273d, 0x273d}, - {0x2776, 0x277f}, {0x2b56, 0x2b59}, {0x3248, 0x324f}, {0xe000, 0xf8ff}, - {0xfe00, 0xfe0f}, {0xfffd, 0xfffd}, {0x1f100, 0x1f10a}, {0x1f110, 0x1f12d}, - {0x1f130, 0x1f169}, {0x1f170, 0x1f18d}, {0x1f18f, 0x1f190}, {0x1f19b, 0x1f1ac}, - {0xe0100, 0xe01ef}, {0xf0000, 0xffffd}, {0x100000, 0x10fffd}, -}; - -static const struct wcwidth9_interval wcwidth9_emoji_width[] = { - {0x1f1e6, 0x1f1ff}, {0x1f321, 0x1f321}, {0x1f324, 0x1f32c}, {0x1f336, 0x1f336}, - {0x1f37d, 0x1f37d}, {0x1f396, 0x1f397}, {0x1f399, 0x1f39b}, {0x1f39e, 0x1f39f}, - {0x1f3cb, 0x1f3ce}, {0x1f3d4, 0x1f3df}, {0x1f3f3, 0x1f3f5}, {0x1f3f7, 0x1f3f7}, - {0x1f43f, 0x1f43f}, {0x1f441, 0x1f441}, {0x1f4fd, 0x1f4fd}, {0x1f549, 0x1f54a}, - {0x1f56f, 0x1f570}, {0x1f573, 0x1f579}, {0x1f587, 0x1f587}, {0x1f58a, 0x1f58d}, - {0x1f590, 0x1f590}, {0x1f5a5, 0x1f5a5}, {0x1f5a8, 0x1f5a8}, {0x1f5b1, 0x1f5b2}, - {0x1f5bc, 0x1f5bc}, {0x1f5c2, 0x1f5c4}, {0x1f5d1, 0x1f5d3}, {0x1f5dc, 0x1f5de}, - {0x1f5e1, 0x1f5e1}, {0x1f5e3, 0x1f5e3}, {0x1f5e8, 0x1f5e8}, {0x1f5ef, 0x1f5ef}, - {0x1f5f3, 0x1f5f3}, {0x1f5fa, 0x1f5fa}, {0x1f6cb, 0x1f6cf}, {0x1f6e0, 0x1f6e5}, - {0x1f6e9, 0x1f6e9}, {0x1f6f0, 0x1f6f0}, {0x1f6f3, 0x1f6f3}, -}; - -static const struct wcwidth9_interval wcwidth9_not_assigned[] = { - {0x0378, 0x0379}, {0x0380, 0x0383}, {0x038b, 0x038b}, {0x038d, 0x038d}, - {0x03a2, 0x03a2}, {0x0530, 0x0530}, {0x0557, 0x0558}, {0x0560, 0x0560}, - {0x0588, 0x0588}, {0x058b, 0x058c}, {0x0590, 0x0590}, {0x05c8, 0x05cf}, - {0x05eb, 0x05ef}, {0x05f5, 0x05ff}, {0x061d, 0x061d}, {0x070e, 0x070e}, - {0x074b, 0x074c}, {0x07b2, 0x07bf}, {0x07fb, 0x07ff}, {0x082e, 0x082f}, - {0x083f, 0x083f}, {0x085c, 0x085d}, {0x085f, 0x089f}, {0x08b5, 0x08b5}, - {0x08be, 0x08d3}, {0x0984, 0x0984}, {0x098d, 0x098e}, {0x0991, 0x0992}, - {0x09a9, 0x09a9}, {0x09b1, 0x09b1}, {0x09b3, 0x09b5}, {0x09ba, 0x09bb}, - {0x09c5, 0x09c6}, {0x09c9, 0x09ca}, {0x09cf, 0x09d6}, {0x09d8, 0x09db}, - {0x09de, 0x09de}, {0x09e4, 0x09e5}, {0x09fc, 0x0a00}, {0x0a04, 0x0a04}, - {0x0a0b, 0x0a0e}, {0x0a11, 0x0a12}, {0x0a29, 0x0a29}, {0x0a31, 0x0a31}, - {0x0a34, 0x0a34}, {0x0a37, 0x0a37}, {0x0a3a, 0x0a3b}, {0x0a3d, 0x0a3d}, - {0x0a43, 0x0a46}, {0x0a49, 0x0a4a}, {0x0a4e, 0x0a50}, {0x0a52, 0x0a58}, - {0x0a5d, 0x0a5d}, {0x0a5f, 0x0a65}, {0x0a76, 0x0a80}, {0x0a84, 0x0a84}, - {0x0a8e, 0x0a8e}, {0x0a92, 0x0a92}, {0x0aa9, 0x0aa9}, {0x0ab1, 0x0ab1}, - {0x0ab4, 0x0ab4}, {0x0aba, 0x0abb}, {0x0ac6, 0x0ac6}, {0x0aca, 0x0aca}, - {0x0ace, 0x0acf}, {0x0ad1, 0x0adf}, {0x0ae4, 0x0ae5}, {0x0af2, 0x0af8}, - {0x0afa, 0x0b00}, {0x0b04, 0x0b04}, {0x0b0d, 0x0b0e}, {0x0b11, 0x0b12}, - {0x0b29, 0x0b29}, {0x0b31, 0x0b31}, {0x0b34, 0x0b34}, {0x0b3a, 0x0b3b}, - {0x0b45, 0x0b46}, {0x0b49, 0x0b4a}, {0x0b4e, 0x0b55}, {0x0b58, 0x0b5b}, - {0x0b5e, 0x0b5e}, {0x0b64, 0x0b65}, {0x0b78, 0x0b81}, {0x0b84, 0x0b84}, - {0x0b8b, 0x0b8d}, {0x0b91, 0x0b91}, {0x0b96, 0x0b98}, {0x0b9b, 0x0b9b}, - {0x0b9d, 0x0b9d}, {0x0ba0, 0x0ba2}, {0x0ba5, 0x0ba7}, {0x0bab, 0x0bad}, - {0x0bba, 0x0bbd}, {0x0bc3, 0x0bc5}, {0x0bc9, 0x0bc9}, {0x0bce, 0x0bcf}, - {0x0bd1, 0x0bd6}, {0x0bd8, 0x0be5}, {0x0bfb, 0x0bff}, {0x0c04, 0x0c04}, - {0x0c0d, 0x0c0d}, {0x0c11, 0x0c11}, {0x0c29, 0x0c29}, {0x0c3a, 0x0c3c}, - {0x0c45, 0x0c45}, {0x0c49, 0x0c49}, {0x0c4e, 0x0c54}, {0x0c57, 0x0c57}, - {0x0c5b, 0x0c5f}, {0x0c64, 0x0c65}, {0x0c70, 0x0c77}, {0x0c84, 0x0c84}, - {0x0c8d, 0x0c8d}, {0x0c91, 0x0c91}, {0x0ca9, 0x0ca9}, {0x0cb4, 0x0cb4}, - {0x0cba, 0x0cbb}, {0x0cc5, 0x0cc5}, {0x0cc9, 0x0cc9}, {0x0cce, 0x0cd4}, - {0x0cd7, 0x0cdd}, {0x0cdf, 0x0cdf}, {0x0ce4, 0x0ce5}, {0x0cf0, 0x0cf0}, - {0x0cf3, 0x0d00}, {0x0d04, 0x0d04}, {0x0d0d, 0x0d0d}, {0x0d11, 0x0d11}, - {0x0d3b, 0x0d3c}, {0x0d45, 0x0d45}, {0x0d49, 0x0d49}, {0x0d50, 0x0d53}, - {0x0d64, 0x0d65}, {0x0d80, 0x0d81}, {0x0d84, 0x0d84}, {0x0d97, 0x0d99}, - {0x0db2, 0x0db2}, {0x0dbc, 0x0dbc}, {0x0dbe, 0x0dbf}, {0x0dc7, 0x0dc9}, - {0x0dcb, 0x0dce}, {0x0dd5, 0x0dd5}, {0x0dd7, 0x0dd7}, {0x0de0, 0x0de5}, - {0x0df0, 0x0df1}, {0x0df5, 0x0e00}, {0x0e3b, 0x0e3e}, {0x0e5c, 0x0e80}, - {0x0e83, 0x0e83}, {0x0e85, 0x0e86}, {0x0e89, 0x0e89}, {0x0e8b, 0x0e8c}, - {0x0e8e, 0x0e93}, {0x0e98, 0x0e98}, {0x0ea0, 0x0ea0}, {0x0ea4, 0x0ea4}, - {0x0ea6, 0x0ea6}, {0x0ea8, 0x0ea9}, {0x0eac, 0x0eac}, {0x0eba, 0x0eba}, - {0x0ebe, 0x0ebf}, {0x0ec5, 0x0ec5}, {0x0ec7, 0x0ec7}, {0x0ece, 0x0ecf}, - {0x0eda, 0x0edb}, {0x0ee0, 0x0eff}, {0x0f48, 0x0f48}, {0x0f6d, 0x0f70}, - {0x0f98, 0x0f98}, {0x0fbd, 0x0fbd}, {0x0fcd, 0x0fcd}, {0x0fdb, 0x0fff}, - {0x10c6, 0x10c6}, {0x10c8, 0x10cc}, {0x10ce, 0x10cf}, {0x1249, 0x1249}, - {0x124e, 0x124f}, {0x1257, 0x1257}, {0x1259, 0x1259}, {0x125e, 0x125f}, - {0x1289, 0x1289}, {0x128e, 0x128f}, {0x12b1, 0x12b1}, {0x12b6, 0x12b7}, - {0x12bf, 0x12bf}, {0x12c1, 0x12c1}, {0x12c6, 0x12c7}, {0x12d7, 0x12d7}, - {0x1311, 0x1311}, {0x1316, 0x1317}, {0x135b, 0x135c}, {0x137d, 0x137f}, - {0x139a, 0x139f}, {0x13f6, 0x13f7}, {0x13fe, 0x13ff}, {0x169d, 0x169f}, - {0x16f9, 0x16ff}, {0x170d, 0x170d}, {0x1715, 0x171f}, {0x1737, 0x173f}, - {0x1754, 0x175f}, {0x176d, 0x176d}, {0x1771, 0x1771}, {0x1774, 0x177f}, - {0x17de, 0x17df}, {0x17ea, 0x17ef}, {0x17fa, 0x17ff}, {0x180f, 0x180f}, - {0x181a, 0x181f}, {0x1878, 0x187f}, {0x18ab, 0x18af}, {0x18f6, 0x18ff}, - {0x191f, 0x191f}, {0x192c, 0x192f}, {0x193c, 0x193f}, {0x1941, 0x1943}, - {0x196e, 0x196f}, {0x1975, 0x197f}, {0x19ac, 0x19af}, {0x19ca, 0x19cf}, - {0x19db, 0x19dd}, {0x1a1c, 0x1a1d}, {0x1a5f, 0x1a5f}, {0x1a7d, 0x1a7e}, - {0x1a8a, 0x1a8f}, {0x1a9a, 0x1a9f}, {0x1aae, 0x1aaf}, {0x1abf, 0x1aff}, - {0x1b4c, 0x1b4f}, {0x1b7d, 0x1b7f}, {0x1bf4, 0x1bfb}, {0x1c38, 0x1c3a}, - {0x1c4a, 0x1c4c}, {0x1c89, 0x1cbf}, {0x1cc8, 0x1ccf}, {0x1cf7, 0x1cf7}, - {0x1cfa, 0x1cff}, {0x1df6, 0x1dfa}, {0x1f16, 0x1f17}, {0x1f1e, 0x1f1f}, - {0x1f46, 0x1f47}, {0x1f4e, 0x1f4f}, {0x1f58, 0x1f58}, {0x1f5a, 0x1f5a}, - {0x1f5c, 0x1f5c}, {0x1f5e, 0x1f5e}, {0x1f7e, 0x1f7f}, {0x1fb5, 0x1fb5}, - {0x1fc5, 0x1fc5}, {0x1fd4, 0x1fd5}, {0x1fdc, 0x1fdc}, {0x1ff0, 0x1ff1}, - {0x1ff5, 0x1ff5}, {0x1fff, 0x1fff}, {0x2065, 0x2065}, {0x2072, 0x2073}, - {0x208f, 0x208f}, {0x209d, 0x209f}, {0x20bf, 0x20cf}, {0x20f1, 0x20ff}, - {0x218c, 0x218f}, {0x23ff, 0x23ff}, {0x2427, 0x243f}, {0x244b, 0x245f}, - {0x2b74, 0x2b75}, {0x2b96, 0x2b97}, {0x2bba, 0x2bbc}, {0x2bc9, 0x2bc9}, - {0x2bd2, 0x2beb}, {0x2bf0, 0x2bff}, {0x2c2f, 0x2c2f}, {0x2c5f, 0x2c5f}, - {0x2cf4, 0x2cf8}, {0x2d26, 0x2d26}, {0x2d28, 0x2d2c}, {0x2d2e, 0x2d2f}, - {0x2d68, 0x2d6e}, {0x2d71, 0x2d7e}, {0x2d97, 0x2d9f}, {0x2da7, 0x2da7}, - {0x2daf, 0x2daf}, {0x2db7, 0x2db7}, {0x2dbf, 0x2dbf}, {0x2dc7, 0x2dc7}, - {0x2dcf, 0x2dcf}, {0x2dd7, 0x2dd7}, {0x2ddf, 0x2ddf}, {0x2e45, 0x2e7f}, - {0x2e9a, 0x2e9a}, {0x2ef4, 0x2eff}, {0x2fd6, 0x2fef}, {0x2ffc, 0x2fff}, - {0x3040, 0x3040}, {0x3097, 0x3098}, {0x3100, 0x3104}, {0x312e, 0x3130}, - {0x318f, 0x318f}, {0x31bb, 0x31bf}, {0x31e4, 0x31ef}, {0x321f, 0x321f}, - {0x32ff, 0x32ff}, {0x4db6, 0x4dbf}, {0x9fd6, 0x9fff}, {0xa48d, 0xa48f}, - {0xa4c7, 0xa4cf}, {0xa62c, 0xa63f}, {0xa6f8, 0xa6ff}, {0xa7af, 0xa7af}, - {0xa7b8, 0xa7f6}, {0xa82c, 0xa82f}, {0xa83a, 0xa83f}, {0xa878, 0xa87f}, - {0xa8c6, 0xa8cd}, {0xa8da, 0xa8df}, {0xa8fe, 0xa8ff}, {0xa954, 0xa95e}, - {0xa97d, 0xa97f}, {0xa9ce, 0xa9ce}, {0xa9da, 0xa9dd}, {0xa9ff, 0xa9ff}, - {0xaa37, 0xaa3f}, {0xaa4e, 0xaa4f}, {0xaa5a, 0xaa5b}, {0xaac3, 0xaada}, - {0xaaf7, 0xab00}, {0xab07, 0xab08}, {0xab0f, 0xab10}, {0xab17, 0xab1f}, - {0xab27, 0xab27}, {0xab2f, 0xab2f}, {0xab66, 0xab6f}, {0xabee, 0xabef}, - {0xabfa, 0xabff}, {0xd7a4, 0xd7af}, {0xd7c7, 0xd7ca}, {0xd7fc, 0xd7ff}, - {0xfa6e, 0xfa6f}, {0xfada, 0xfaff}, {0xfb07, 0xfb12}, {0xfb18, 0xfb1c}, - {0xfb37, 0xfb37}, {0xfb3d, 0xfb3d}, {0xfb3f, 0xfb3f}, {0xfb42, 0xfb42}, - {0xfb45, 0xfb45}, {0xfbc2, 0xfbd2}, {0xfd40, 0xfd4f}, {0xfd90, 0xfd91}, - {0xfdc8, 0xfdef}, {0xfdfe, 0xfdff}, {0xfe1a, 0xfe1f}, {0xfe53, 0xfe53}, - {0xfe67, 0xfe67}, {0xfe6c, 0xfe6f}, {0xfe75, 0xfe75}, {0xfefd, 0xfefe}, - {0xff00, 0xff00}, {0xffbf, 0xffc1}, {0xffc8, 0xffc9}, {0xffd0, 0xffd1}, - {0xffd8, 0xffd9}, {0xffdd, 0xffdf}, {0xffe7, 0xffe7}, {0xffef, 0xfff8}, - {0xfffe, 0xffff}, {0x1000c, 0x1000c}, {0x10027, 0x10027}, {0x1003b, 0x1003b}, - {0x1003e, 0x1003e}, {0x1004e, 0x1004f}, {0x1005e, 0x1007f}, {0x100fb, 0x100ff}, - {0x10103, 0x10106}, {0x10134, 0x10136}, {0x1018f, 0x1018f}, {0x1019c, 0x1019f}, - {0x101a1, 0x101cf}, {0x101fe, 0x1027f}, {0x1029d, 0x1029f}, {0x102d1, 0x102df}, - {0x102fc, 0x102ff}, {0x10324, 0x1032f}, {0x1034b, 0x1034f}, {0x1037b, 0x1037f}, - {0x1039e, 0x1039e}, {0x103c4, 0x103c7}, {0x103d6, 0x103ff}, {0x1049e, 0x1049f}, - {0x104aa, 0x104af}, {0x104d4, 0x104d7}, {0x104fc, 0x104ff}, {0x10528, 0x1052f}, - {0x10564, 0x1056e}, {0x10570, 0x105ff}, {0x10737, 0x1073f}, {0x10756, 0x1075f}, - {0x10768, 0x107ff}, {0x10806, 0x10807}, {0x10809, 0x10809}, {0x10836, 0x10836}, - {0x10839, 0x1083b}, {0x1083d, 0x1083e}, {0x10856, 0x10856}, {0x1089f, 0x108a6}, - {0x108b0, 0x108df}, {0x108f3, 0x108f3}, {0x108f6, 0x108fa}, {0x1091c, 0x1091e}, - {0x1093a, 0x1093e}, {0x10940, 0x1097f}, {0x109b8, 0x109bb}, {0x109d0, 0x109d1}, - {0x10a04, 0x10a04}, {0x10a07, 0x10a0b}, {0x10a14, 0x10a14}, {0x10a18, 0x10a18}, - {0x10a34, 0x10a37}, {0x10a3b, 0x10a3e}, {0x10a48, 0x10a4f}, {0x10a59, 0x10a5f}, - {0x10aa0, 0x10abf}, {0x10ae7, 0x10aea}, {0x10af7, 0x10aff}, {0x10b36, 0x10b38}, - {0x10b56, 0x10b57}, {0x10b73, 0x10b77}, {0x10b92, 0x10b98}, {0x10b9d, 0x10ba8}, - {0x10bb0, 0x10bff}, {0x10c49, 0x10c7f}, {0x10cb3, 0x10cbf}, {0x10cf3, 0x10cf9}, - {0x10d00, 0x10e5f}, {0x10e7f, 0x10fff}, {0x1104e, 0x11051}, {0x11070, 0x1107e}, - {0x110c2, 0x110cf}, {0x110e9, 0x110ef}, {0x110fa, 0x110ff}, {0x11135, 0x11135}, - {0x11144, 0x1114f}, {0x11177, 0x1117f}, {0x111ce, 0x111cf}, {0x111e0, 0x111e0}, - {0x111f5, 0x111ff}, {0x11212, 0x11212}, {0x1123f, 0x1127f}, {0x11287, 0x11287}, - {0x11289, 0x11289}, {0x1128e, 0x1128e}, {0x1129e, 0x1129e}, {0x112aa, 0x112af}, - {0x112eb, 0x112ef}, {0x112fa, 0x112ff}, {0x11304, 0x11304}, {0x1130d, 0x1130e}, - {0x11311, 0x11312}, {0x11329, 0x11329}, {0x11331, 0x11331}, {0x11334, 0x11334}, - {0x1133a, 0x1133b}, {0x11345, 0x11346}, {0x11349, 0x1134a}, {0x1134e, 0x1134f}, - {0x11351, 0x11356}, {0x11358, 0x1135c}, {0x11364, 0x11365}, {0x1136d, 0x1136f}, - {0x11375, 0x113ff}, {0x1145a, 0x1145a}, {0x1145c, 0x1145c}, {0x1145e, 0x1147f}, - {0x114c8, 0x114cf}, {0x114da, 0x1157f}, {0x115b6, 0x115b7}, {0x115de, 0x115ff}, - {0x11645, 0x1164f}, {0x1165a, 0x1165f}, {0x1166d, 0x1167f}, {0x116b8, 0x116bf}, - {0x116ca, 0x116ff}, {0x1171a, 0x1171c}, {0x1172c, 0x1172f}, {0x11740, 0x1189f}, - {0x118f3, 0x118fe}, {0x11900, 0x11abf}, {0x11af9, 0x11bff}, {0x11c09, 0x11c09}, - {0x11c37, 0x11c37}, {0x11c46, 0x11c4f}, {0x11c6d, 0x11c6f}, {0x11c90, 0x11c91}, - {0x11ca8, 0x11ca8}, {0x11cb7, 0x11fff}, {0x1239a, 0x123ff}, {0x1246f, 0x1246f}, - {0x12475, 0x1247f}, {0x12544, 0x12fff}, {0x1342f, 0x143ff}, {0x14647, 0x167ff}, - {0x16a39, 0x16a3f}, {0x16a5f, 0x16a5f}, {0x16a6a, 0x16a6d}, {0x16a70, 0x16acf}, - {0x16aee, 0x16aef}, {0x16af6, 0x16aff}, {0x16b46, 0x16b4f}, {0x16b5a, 0x16b5a}, - {0x16b62, 0x16b62}, {0x16b78, 0x16b7c}, {0x16b90, 0x16eff}, {0x16f45, 0x16f4f}, - {0x16f7f, 0x16f8e}, {0x16fa0, 0x16fdf}, {0x16fe1, 0x16fff}, {0x187ed, 0x187ff}, - {0x18af3, 0x1afff}, {0x1b002, 0x1bbff}, {0x1bc6b, 0x1bc6f}, {0x1bc7d, 0x1bc7f}, - {0x1bc89, 0x1bc8f}, {0x1bc9a, 0x1bc9b}, {0x1bca4, 0x1cfff}, {0x1d0f6, 0x1d0ff}, - {0x1d127, 0x1d128}, {0x1d1e9, 0x1d1ff}, {0x1d246, 0x1d2ff}, {0x1d357, 0x1d35f}, - {0x1d372, 0x1d3ff}, {0x1d455, 0x1d455}, {0x1d49d, 0x1d49d}, {0x1d4a0, 0x1d4a1}, - {0x1d4a3, 0x1d4a4}, {0x1d4a7, 0x1d4a8}, {0x1d4ad, 0x1d4ad}, {0x1d4ba, 0x1d4ba}, - {0x1d4bc, 0x1d4bc}, {0x1d4c4, 0x1d4c4}, {0x1d506, 0x1d506}, {0x1d50b, 0x1d50c}, - {0x1d515, 0x1d515}, {0x1d51d, 0x1d51d}, {0x1d53a, 0x1d53a}, {0x1d53f, 0x1d53f}, - {0x1d545, 0x1d545}, {0x1d547, 0x1d549}, {0x1d551, 0x1d551}, {0x1d6a6, 0x1d6a7}, - {0x1d7cc, 0x1d7cd}, {0x1da8c, 0x1da9a}, {0x1daa0, 0x1daa0}, {0x1dab0, 0x1dfff}, - {0x1e007, 0x1e007}, {0x1e019, 0x1e01a}, {0x1e022, 0x1e022}, {0x1e025, 0x1e025}, - {0x1e02b, 0x1e7ff}, {0x1e8c5, 0x1e8c6}, {0x1e8d7, 0x1e8ff}, {0x1e94b, 0x1e94f}, - {0x1e95a, 0x1e95d}, {0x1e960, 0x1edff}, {0x1ee04, 0x1ee04}, {0x1ee20, 0x1ee20}, - {0x1ee23, 0x1ee23}, {0x1ee25, 0x1ee26}, {0x1ee28, 0x1ee28}, {0x1ee33, 0x1ee33}, - {0x1ee38, 0x1ee38}, {0x1ee3a, 0x1ee3a}, {0x1ee3c, 0x1ee41}, {0x1ee43, 0x1ee46}, - {0x1ee48, 0x1ee48}, {0x1ee4a, 0x1ee4a}, {0x1ee4c, 0x1ee4c}, {0x1ee50, 0x1ee50}, - {0x1ee53, 0x1ee53}, {0x1ee55, 0x1ee56}, {0x1ee58, 0x1ee58}, {0x1ee5a, 0x1ee5a}, - {0x1ee5c, 0x1ee5c}, {0x1ee5e, 0x1ee5e}, {0x1ee60, 0x1ee60}, {0x1ee63, 0x1ee63}, - {0x1ee65, 0x1ee66}, {0x1ee6b, 0x1ee6b}, {0x1ee73, 0x1ee73}, {0x1ee78, 0x1ee78}, - {0x1ee7d, 0x1ee7d}, {0x1ee7f, 0x1ee7f}, {0x1ee8a, 0x1ee8a}, {0x1ee9c, 0x1eea0}, - {0x1eea4, 0x1eea4}, {0x1eeaa, 0x1eeaa}, {0x1eebc, 0x1eeef}, {0x1eef2, 0x1efff}, - {0x1f02c, 0x1f02f}, {0x1f094, 0x1f09f}, {0x1f0af, 0x1f0b0}, {0x1f0c0, 0x1f0c0}, - {0x1f0d0, 0x1f0d0}, {0x1f0f6, 0x1f0ff}, {0x1f10d, 0x1f10f}, {0x1f12f, 0x1f12f}, - {0x1f16c, 0x1f16f}, {0x1f1ad, 0x1f1e5}, {0x1f203, 0x1f20f}, {0x1f23c, 0x1f23f}, - {0x1f249, 0x1f24f}, {0x1f252, 0x1f2ff}, {0x1f6d3, 0x1f6df}, {0x1f6ed, 0x1f6ef}, - {0x1f6f7, 0x1f6ff}, {0x1f774, 0x1f77f}, {0x1f7d5, 0x1f7ff}, {0x1f80c, 0x1f80f}, - {0x1f848, 0x1f84f}, {0x1f85a, 0x1f85f}, {0x1f888, 0x1f88f}, {0x1f8ae, 0x1f90f}, - {0x1f91f, 0x1f91f}, {0x1f928, 0x1f92f}, {0x1f931, 0x1f932}, {0x1f93f, 0x1f93f}, - {0x1f94c, 0x1f94f}, {0x1f95f, 0x1f97f}, {0x1f992, 0x1f9bf}, {0x1f9c1, 0x1ffff}, - {0x2a6d7, 0x2a6ff}, {0x2b735, 0x2b73f}, {0x2b81e, 0x2b81f}, {0x2cea2, 0x2f7ff}, - {0x2fa1e, 0xe0000}, {0xe0002, 0xe001f}, {0xe0080, 0xe00ff}, {0xe01f0, 0xeffff}, - {0xffffe, 0xfffff}, -}; - -#define WCWIDTH9_ARRAY_SIZE(arr) \ - ((sizeof(arr) / sizeof((arr)[0])) / ((size_t)(!(sizeof(arr) % sizeof((arr)[0]))))) - -static inline bool wcwidth9_intable(const struct wcwidth9_interval *table, size_t n_items, int c) { - int mid, bot, top; - - if (c < table[0].first) { - return false; - } - - bot = 0; - top = (int)(n_items - 1); - while (top >= bot) { - mid = (bot + top) / 2; - - if (table[mid].last < c) { - bot = mid + 1; - } else if (table[mid].first > c) { - top = mid - 1; - } else { - return true; - } - } - - return false; -} - -static inline int wcwidth9(int c) { - if (c < 0 || c > 0x10ffff) { - return -1; - } - - if (wcwidth9_intable(wcwidth9_nonprint, WCWIDTH9_ARRAY_SIZE(wcwidth9_nonprint), c)) { - return -1; - } - - if (wcwidth9_intable(wcwidth9_combining, WCWIDTH9_ARRAY_SIZE(wcwidth9_combining), c)) { - return -1; - } - - if (wcwidth9_intable(wcwidth9_not_assigned, WCWIDTH9_ARRAY_SIZE(wcwidth9_not_assigned), c)) { - return -1; - } - - if (wcwidth9_intable(wcwidth9_private, WCWIDTH9_ARRAY_SIZE(wcwidth9_private), c)) { - return -3; - } - - if (wcwidth9_intable(wcwidth9_ambiguous, WCWIDTH9_ARRAY_SIZE(wcwidth9_ambiguous), c)) { - return -2; - } - - if (wcwidth9_intable(wcwidth9_doublewidth, WCWIDTH9_ARRAY_SIZE(wcwidth9_doublewidth), c)) { - return 2; - } - - if (wcwidth9_intable(wcwidth9_emoji_width, WCWIDTH9_ARRAY_SIZE(wcwidth9_emoji_width), c)) { - return 2; - } - - return 1; -} - -#endif /* WCWIDTH9_H */ diff --git a/src/widecharwidth/LICENSE b/src/widecharwidth/LICENSE new file mode 100644 index 000000000..d3b1dd767 --- /dev/null +++ b/src/widecharwidth/LICENSE @@ -0,0 +1,4 @@ +widecharwidth - wcwidth implementation +Written in 2018 by ridiculous_fish +To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. +You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see . diff --git a/src/widecharwidth/widechar_width.h b/src/widecharwidth/widechar_width.h new file mode 100644 index 000000000..b61cc9e99 --- /dev/null +++ b/src/widecharwidth/widechar_width.h @@ -0,0 +1,524 @@ +/** + * widechar_width.h, generated on 2018-07-09. + * See https://github.com/ridiculousfish/widecharwidth/ + * + * SHA1 file hashes: + * UnicodeData.txt: 0e060fafb08d6722fbec56d9f9ebe8509f01d0ee + * EastAsianWidth.txt: 240b5b2c235671d330860742615f798e3d334c4c + * emoji-data.txt: 11fd60a01e17df80035c459728350073cd9ed37b + */ + +#ifndef WIDECHAR_WIDTH_H +#define WIDECHAR_WIDTH_H + +#include +#include +#include +#include + +namespace { + +/* Special width values */ +enum { + widechar_nonprint = -1, // The character is not printable. + widechar_combining = -2, // The character is a zero-width combiner. + widechar_ambiguous = -3, // The character is East-Asian ambiguous width. + widechar_private_use = -4, // The character is for private use. + widechar_unassigned = -5, // The character is unassigned. + widechar_widened_in_9 = -6 // Width is 1 in Unicode 8, 2 in Unicode 9+. +}; + +/* An inclusive range of characters. */ +struct widechar_range { + int32_t lo; + int32_t hi; +}; + +/* Private usage range. */ +static const struct widechar_range widechar_private_table[] = { + {0x0E000, 0x0F8FF}, {0xF0000, 0xFFFFD}, {0x100000, 0x10FFFD} +}; + +/* Nonprinting characters. */ +static const struct widechar_range widechar_nonprint_table[] = { + {0x00000, 0x0001F}, {0x0007F, 0x0009F}, {0x000AD, 0x000AD}, + {0x00600, 0x00605}, {0x0061C, 0x0061C}, {0x006DD, 0x006DD}, + {0x0070F, 0x0070F}, {0x008E2, 0x008E2}, {0x0180E, 0x0180E}, + {0x0200B, 0x0200F}, {0x02028, 0x0202E}, {0x02060, 0x02064}, + {0x02066, 0x0206F}, {0x0D800, 0x0DFFF}, {0x0FEFF, 0x0FEFF}, + {0x0FFF9, 0x0FFFB}, {0x110BD, 0x110BD}, {0x110CD, 0x110CD}, + {0x1BCA0, 0x1BCA3}, {0x1D173, 0x1D17A}, {0xE0001, 0xE0001}, + {0xE0020, 0xE007F} +}; + +/* Width 0 combining marks. */ +static const struct widechar_range widechar_combining_table[] = { + {0x00300, 0x0036F}, {0x00483, 0x00489}, {0x00591, 0x005BD}, + {0x005BF, 0x005BF}, {0x005C1, 0x005C2}, {0x005C4, 0x005C5}, + {0x005C7, 0x005C7}, {0x00610, 0x0061A}, {0x0064B, 0x0065F}, + {0x00670, 0x00670}, {0x006D6, 0x006DC}, {0x006DF, 0x006E4}, + {0x006E7, 0x006E8}, {0x006EA, 0x006ED}, {0x00711, 0x00711}, + {0x00730, 0x0074A}, {0x007A6, 0x007B0}, {0x007EB, 0x007F3}, + {0x007FD, 0x007FD}, {0x00816, 0x00819}, {0x0081B, 0x00823}, + {0x00825, 0x00827}, {0x00829, 0x0082D}, {0x00859, 0x0085B}, + {0x008D3, 0x008E1}, {0x008E3, 0x00903}, {0x0093A, 0x0093C}, + {0x0093E, 0x0094F}, {0x00951, 0x00957}, {0x00962, 0x00963}, + {0x00981, 0x00983}, {0x009BC, 0x009BC}, {0x009BE, 0x009C4}, + {0x009C7, 0x009C8}, {0x009CB, 0x009CD}, {0x009D7, 0x009D7}, + {0x009E2, 0x009E3}, {0x009FE, 0x009FE}, {0x00A01, 0x00A03}, + {0x00A3C, 0x00A3C}, {0x00A3E, 0x00A42}, {0x00A47, 0x00A48}, + {0x00A4B, 0x00A4D}, {0x00A51, 0x00A51}, {0x00A70, 0x00A71}, + {0x00A75, 0x00A75}, {0x00A81, 0x00A83}, {0x00ABC, 0x00ABC}, + {0x00ABE, 0x00AC5}, {0x00AC7, 0x00AC9}, {0x00ACB, 0x00ACD}, + {0x00AE2, 0x00AE3}, {0x00AFA, 0x00AFF}, {0x00B01, 0x00B03}, + {0x00B3C, 0x00B3C}, {0x00B3E, 0x00B44}, {0x00B47, 0x00B48}, + {0x00B4B, 0x00B4D}, {0x00B56, 0x00B57}, {0x00B62, 0x00B63}, + {0x00B82, 0x00B82}, {0x00BBE, 0x00BC2}, {0x00BC6, 0x00BC8}, + {0x00BCA, 0x00BCD}, {0x00BD7, 0x00BD7}, {0x00C00, 0x00C04}, + {0x00C3E, 0x00C44}, {0x00C46, 0x00C48}, {0x00C4A, 0x00C4D}, + {0x00C55, 0x00C56}, {0x00C62, 0x00C63}, {0x00C81, 0x00C83}, + {0x00CBC, 0x00CBC}, {0x00CBE, 0x00CC4}, {0x00CC6, 0x00CC8}, + {0x00CCA, 0x00CCD}, {0x00CD5, 0x00CD6}, {0x00CE2, 0x00CE3}, + {0x00D00, 0x00D03}, {0x00D3B, 0x00D3C}, {0x00D3E, 0x00D44}, + {0x00D46, 0x00D48}, {0x00D4A, 0x00D4D}, {0x00D57, 0x00D57}, + {0x00D62, 0x00D63}, {0x00D82, 0x00D83}, {0x00DCA, 0x00DCA}, + {0x00DCF, 0x00DD4}, {0x00DD6, 0x00DD6}, {0x00DD8, 0x00DDF}, + {0x00DF2, 0x00DF3}, {0x00E31, 0x00E31}, {0x00E34, 0x00E3A}, + {0x00E47, 0x00E4E}, {0x00EB1, 0x00EB1}, {0x00EB4, 0x00EB9}, + {0x00EBB, 0x00EBC}, {0x00EC8, 0x00ECD}, {0x00F18, 0x00F19}, + {0x00F35, 0x00F35}, {0x00F37, 0x00F37}, {0x00F39, 0x00F39}, + {0x00F3E, 0x00F3F}, {0x00F71, 0x00F84}, {0x00F86, 0x00F87}, + {0x00F8D, 0x00F97}, {0x00F99, 0x00FBC}, {0x00FC6, 0x00FC6}, + {0x0102B, 0x0103E}, {0x01056, 0x01059}, {0x0105E, 0x01060}, + {0x01062, 0x01064}, {0x01067, 0x0106D}, {0x01071, 0x01074}, + {0x01082, 0x0108D}, {0x0108F, 0x0108F}, {0x0109A, 0x0109D}, + {0x0135D, 0x0135F}, {0x01712, 0x01714}, {0x01732, 0x01734}, + {0x01752, 0x01753}, {0x01772, 0x01773}, {0x017B4, 0x017D3}, + {0x017DD, 0x017DD}, {0x0180B, 0x0180D}, {0x01885, 0x01886}, + {0x018A9, 0x018A9}, {0x01920, 0x0192B}, {0x01930, 0x0193B}, + {0x01A17, 0x01A1B}, {0x01A55, 0x01A5E}, {0x01A60, 0x01A7C}, + {0x01A7F, 0x01A7F}, {0x01AB0, 0x01ABE}, {0x01B00, 0x01B04}, + {0x01B34, 0x01B44}, {0x01B6B, 0x01B73}, {0x01B80, 0x01B82}, + {0x01BA1, 0x01BAD}, {0x01BE6, 0x01BF3}, {0x01C24, 0x01C37}, + {0x01CD0, 0x01CD2}, {0x01CD4, 0x01CE8}, {0x01CED, 0x01CED}, + {0x01CF2, 0x01CF4}, {0x01CF7, 0x01CF9}, {0x01DC0, 0x01DF9}, + {0x01DFB, 0x01DFF}, {0x020D0, 0x020F0}, {0x02CEF, 0x02CF1}, + {0x02D7F, 0x02D7F}, {0x02DE0, 0x02DFF}, {0x0302A, 0x0302F}, + {0x03099, 0x0309A}, {0x0A66F, 0x0A672}, {0x0A674, 0x0A67D}, + {0x0A69E, 0x0A69F}, {0x0A6F0, 0x0A6F1}, {0x0A802, 0x0A802}, + {0x0A806, 0x0A806}, {0x0A80B, 0x0A80B}, {0x0A823, 0x0A827}, + {0x0A880, 0x0A881}, {0x0A8B4, 0x0A8C5}, {0x0A8E0, 0x0A8F1}, + {0x0A8FF, 0x0A8FF}, {0x0A926, 0x0A92D}, {0x0A947, 0x0A953}, + {0x0A980, 0x0A983}, {0x0A9B3, 0x0A9C0}, {0x0A9E5, 0x0A9E5}, + {0x0AA29, 0x0AA36}, {0x0AA43, 0x0AA43}, {0x0AA4C, 0x0AA4D}, + {0x0AA7B, 0x0AA7D}, {0x0AAB0, 0x0AAB0}, {0x0AAB2, 0x0AAB4}, + {0x0AAB7, 0x0AAB8}, {0x0AABE, 0x0AABF}, {0x0AAC1, 0x0AAC1}, + {0x0AAEB, 0x0AAEF}, {0x0AAF5, 0x0AAF6}, {0x0ABE3, 0x0ABEA}, + {0x0ABEC, 0x0ABED}, {0x0FB1E, 0x0FB1E}, {0x0FE00, 0x0FE0F}, + {0x0FE20, 0x0FE2F}, {0x101FD, 0x101FD}, {0x102E0, 0x102E0}, + {0x10376, 0x1037A}, {0x10A01, 0x10A03}, {0x10A05, 0x10A06}, + {0x10A0C, 0x10A0F}, {0x10A38, 0x10A3A}, {0x10A3F, 0x10A3F}, + {0x10AE5, 0x10AE6}, {0x10D24, 0x10D27}, {0x10F46, 0x10F50}, + {0x11000, 0x11002}, {0x11038, 0x11046}, {0x1107F, 0x11082}, + {0x110B0, 0x110BA}, {0x11100, 0x11102}, {0x11127, 0x11134}, + {0x11145, 0x11146}, {0x11173, 0x11173}, {0x11180, 0x11182}, + {0x111B3, 0x111C0}, {0x111C9, 0x111CC}, {0x1122C, 0x11237}, + {0x1123E, 0x1123E}, {0x112DF, 0x112EA}, {0x11300, 0x11303}, + {0x1133B, 0x1133C}, {0x1133E, 0x11344}, {0x11347, 0x11348}, + {0x1134B, 0x1134D}, {0x11357, 0x11357}, {0x11362, 0x11363}, + {0x11366, 0x1136C}, {0x11370, 0x11374}, {0x11435, 0x11446}, + {0x1145E, 0x1145E}, {0x114B0, 0x114C3}, {0x115AF, 0x115B5}, + {0x115B8, 0x115C0}, {0x115DC, 0x115DD}, {0x11630, 0x11640}, + {0x116AB, 0x116B7}, {0x1171D, 0x1172B}, {0x1182C, 0x1183A}, + {0x11A01, 0x11A0A}, {0x11A33, 0x11A39}, {0x11A3B, 0x11A3E}, + {0x11A47, 0x11A47}, {0x11A51, 0x11A5B}, {0x11A8A, 0x11A99}, + {0x11C2F, 0x11C36}, {0x11C38, 0x11C3F}, {0x11C92, 0x11CA7}, + {0x11CA9, 0x11CB6}, {0x11D31, 0x11D36}, {0x11D3A, 0x11D3A}, + {0x11D3C, 0x11D3D}, {0x11D3F, 0x11D45}, {0x11D47, 0x11D47}, + {0x11D8A, 0x11D8E}, {0x11D90, 0x11D91}, {0x11D93, 0x11D97}, + {0x11EF3, 0x11EF6}, {0x16AF0, 0x16AF4}, {0x16B30, 0x16B36}, + {0x16F51, 0x16F7E}, {0x16F8F, 0x16F92}, {0x1BC9D, 0x1BC9E}, + {0x1D165, 0x1D169}, {0x1D16D, 0x1D172}, {0x1D17B, 0x1D182}, + {0x1D185, 0x1D18B}, {0x1D1AA, 0x1D1AD}, {0x1D242, 0x1D244}, + {0x1DA00, 0x1DA36}, {0x1DA3B, 0x1DA6C}, {0x1DA75, 0x1DA75}, + {0x1DA84, 0x1DA84}, {0x1DA9B, 0x1DA9F}, {0x1DAA1, 0x1DAAF}, + {0x1E000, 0x1E006}, {0x1E008, 0x1E018}, {0x1E01B, 0x1E021}, + {0x1E023, 0x1E024}, {0x1E026, 0x1E02A}, {0x1E8D0, 0x1E8D6}, + {0x1E944, 0x1E94A}, {0xE0100, 0xE01EF} +}; + +/* Width.2 characters. */ +static const struct widechar_range widechar_doublewide_table[] = { + {0x01100, 0x0115F}, {0x0231A, 0x0231B}, {0x02329, 0x0232A}, + {0x023E9, 0x023EC}, {0x023F0, 0x023F0}, {0x023F3, 0x023F3}, + {0x025FD, 0x025FE}, {0x02614, 0x02615}, {0x02648, 0x02653}, + {0x0267F, 0x0267F}, {0x02693, 0x02693}, {0x026A1, 0x026A1}, + {0x026AA, 0x026AB}, {0x026BD, 0x026BE}, {0x026C4, 0x026C5}, + {0x026CE, 0x026CE}, {0x026D4, 0x026D4}, {0x026EA, 0x026EA}, + {0x026F2, 0x026F3}, {0x026F5, 0x026F5}, {0x026FA, 0x026FA}, + {0x026FD, 0x026FD}, {0x02705, 0x02705}, {0x0270A, 0x0270B}, + {0x02728, 0x02728}, {0x0274C, 0x0274C}, {0x0274E, 0x0274E}, + {0x02753, 0x02755}, {0x02757, 0x02757}, {0x02795, 0x02797}, + {0x027B0, 0x027B0}, {0x027BF, 0x027BF}, {0x02B1B, 0x02B1C}, + {0x02B50, 0x02B50}, {0x02B55, 0x02B55}, {0x02E80, 0x02E99}, + {0x02E9B, 0x02EF3}, {0x02F00, 0x02FD5}, {0x02FF0, 0x02FFB}, + {0x03000, 0x0303E}, {0x03041, 0x03096}, {0x03099, 0x030FF}, + {0x03105, 0x0312F}, {0x03131, 0x0318E}, {0x03190, 0x031BA}, + {0x031C0, 0x031E3}, {0x031F0, 0x0321E}, {0x03220, 0x03247}, + {0x03250, 0x032FE}, {0x03300, 0x04DBF}, {0x04E00, 0x0A48C}, + {0x0A490, 0x0A4C6}, {0x0A960, 0x0A97C}, {0x0AC00, 0x0D7A3}, + {0x0F900, 0x0FAFF}, {0x0FE10, 0x0FE19}, {0x0FE30, 0x0FE52}, + {0x0FE54, 0x0FE66}, {0x0FE68, 0x0FE6B}, {0x0FF01, 0x0FF60}, + {0x0FFE0, 0x0FFE6}, {0x16FE0, 0x16FE1}, {0x17000, 0x187F1}, + {0x18800, 0x18AF2}, {0x1B000, 0x1B11E}, {0x1B170, 0x1B2FB}, + {0x1F200, 0x1F200}, {0x1F210, 0x1F219}, {0x1F21B, 0x1F22E}, + {0x1F230, 0x1F231}, {0x1F23B, 0x1F23B}, {0x1F240, 0x1F248}, + {0x1F260, 0x1F265}, {0x1F57A, 0x1F57A}, {0x1F5A4, 0x1F5A4}, + {0x1F6D1, 0x1F6D2}, {0x1F6F4, 0x1F6F9}, {0x1F919, 0x1F93E}, + {0x1F940, 0x1F970}, {0x1F973, 0x1F976}, {0x1F97A, 0x1F97A}, + {0x1F97C, 0x1F97F}, {0x1F985, 0x1F9A2}, {0x1F9B0, 0x1F9B9}, + {0x1F9C1, 0x1F9C2}, {0x1F9D0, 0x1F9FF}, {0x20000, 0x2FFFD}, + {0x30000, 0x3FFFD} +}; + +/* Ambiguous-width characters. */ +static const struct widechar_range widechar_ambiguous_table[] = { + {0x000A1, 0x000A1}, {0x000A4, 0x000A4}, {0x000A7, 0x000A8}, + {0x000AA, 0x000AA}, {0x000AD, 0x000AE}, {0x000B0, 0x000B4}, + {0x000B6, 0x000BA}, {0x000BC, 0x000BF}, {0x000C6, 0x000C6}, + {0x000D0, 0x000D0}, {0x000D7, 0x000D8}, {0x000DE, 0x000E1}, + {0x000E6, 0x000E6}, {0x000E8, 0x000EA}, {0x000EC, 0x000ED}, + {0x000F0, 0x000F0}, {0x000F2, 0x000F3}, {0x000F7, 0x000FA}, + {0x000FC, 0x000FC}, {0x000FE, 0x000FE}, {0x00101, 0x00101}, + {0x00111, 0x00111}, {0x00113, 0x00113}, {0x0011B, 0x0011B}, + {0x00126, 0x00127}, {0x0012B, 0x0012B}, {0x00131, 0x00133}, + {0x00138, 0x00138}, {0x0013F, 0x00142}, {0x00144, 0x00144}, + {0x00148, 0x0014B}, {0x0014D, 0x0014D}, {0x00152, 0x00153}, + {0x00166, 0x00167}, {0x0016B, 0x0016B}, {0x001CE, 0x001CE}, + {0x001D0, 0x001D0}, {0x001D2, 0x001D2}, {0x001D4, 0x001D4}, + {0x001D6, 0x001D6}, {0x001D8, 0x001D8}, {0x001DA, 0x001DA}, + {0x001DC, 0x001DC}, {0x00251, 0x00251}, {0x00261, 0x00261}, + {0x002C4, 0x002C4}, {0x002C7, 0x002C7}, {0x002C9, 0x002CB}, + {0x002CD, 0x002CD}, {0x002D0, 0x002D0}, {0x002D8, 0x002DB}, + {0x002DD, 0x002DD}, {0x002DF, 0x002DF}, {0x00300, 0x0036F}, + {0x00391, 0x003A1}, {0x003A3, 0x003A9}, {0x003B1, 0x003C1}, + {0x003C3, 0x003C9}, {0x00401, 0x00401}, {0x00410, 0x0044F}, + {0x00451, 0x00451}, {0x02010, 0x02010}, {0x02013, 0x02016}, + {0x02018, 0x02019}, {0x0201C, 0x0201D}, {0x02020, 0x02022}, + {0x02024, 0x02027}, {0x02030, 0x02030}, {0x02032, 0x02033}, + {0x02035, 0x02035}, {0x0203B, 0x0203B}, {0x0203E, 0x0203E}, + {0x02074, 0x02074}, {0x0207F, 0x0207F}, {0x02081, 0x02084}, + {0x020AC, 0x020AC}, {0x02103, 0x02103}, {0x02105, 0x02105}, + {0x02109, 0x02109}, {0x02113, 0x02113}, {0x02116, 0x02116}, + {0x02121, 0x02122}, {0x02126, 0x02126}, {0x0212B, 0x0212B}, + {0x02153, 0x02154}, {0x0215B, 0x0215E}, {0x02160, 0x0216B}, + {0x02170, 0x02179}, {0x02189, 0x02189}, {0x02190, 0x02199}, + {0x021B8, 0x021B9}, {0x021D2, 0x021D2}, {0x021D4, 0x021D4}, + {0x021E7, 0x021E7}, {0x02200, 0x02200}, {0x02202, 0x02203}, + {0x02207, 0x02208}, {0x0220B, 0x0220B}, {0x0220F, 0x0220F}, + {0x02211, 0x02211}, {0x02215, 0x02215}, {0x0221A, 0x0221A}, + {0x0221D, 0x02220}, {0x02223, 0x02223}, {0x02225, 0x02225}, + {0x02227, 0x0222C}, {0x0222E, 0x0222E}, {0x02234, 0x02237}, + {0x0223C, 0x0223D}, {0x02248, 0x02248}, {0x0224C, 0x0224C}, + {0x02252, 0x02252}, {0x02260, 0x02261}, {0x02264, 0x02267}, + {0x0226A, 0x0226B}, {0x0226E, 0x0226F}, {0x02282, 0x02283}, + {0x02286, 0x02287}, {0x02295, 0x02295}, {0x02299, 0x02299}, + {0x022A5, 0x022A5}, {0x022BF, 0x022BF}, {0x02312, 0x02312}, + {0x02460, 0x024E9}, {0x024EB, 0x0254B}, {0x02550, 0x02573}, + {0x02580, 0x0258F}, {0x02592, 0x02595}, {0x025A0, 0x025A1}, + {0x025A3, 0x025A9}, {0x025B2, 0x025B3}, {0x025B6, 0x025B7}, + {0x025BC, 0x025BD}, {0x025C0, 0x025C1}, {0x025C6, 0x025C8}, + {0x025CB, 0x025CB}, {0x025CE, 0x025D1}, {0x025E2, 0x025E5}, + {0x025EF, 0x025EF}, {0x02605, 0x02606}, {0x02609, 0x02609}, + {0x0260E, 0x0260F}, {0x0261C, 0x0261C}, {0x0261E, 0x0261E}, + {0x02640, 0x02640}, {0x02642, 0x02642}, {0x02660, 0x02661}, + {0x02663, 0x02665}, {0x02667, 0x0266A}, {0x0266C, 0x0266D}, + {0x0266F, 0x0266F}, {0x0269E, 0x0269F}, {0x026BF, 0x026BF}, + {0x026C6, 0x026CD}, {0x026CF, 0x026D3}, {0x026D5, 0x026E1}, + {0x026E3, 0x026E3}, {0x026E8, 0x026E9}, {0x026EB, 0x026F1}, + {0x026F4, 0x026F4}, {0x026F6, 0x026F9}, {0x026FB, 0x026FC}, + {0x026FE, 0x026FF}, {0x0273D, 0x0273D}, {0x02776, 0x0277F}, + {0x02B56, 0x02B59}, {0x03248, 0x0324F}, {0x0E000, 0x0F8FF}, + {0x0FE00, 0x0FE0F}, {0x0FFFD, 0x0FFFD}, {0x1F100, 0x1F10A}, + {0x1F110, 0x1F12D}, {0x1F130, 0x1F169}, {0x1F172, 0x1F17D}, + {0x1F180, 0x1F18D}, {0x1F18F, 0x1F190}, {0x1F19B, 0x1F1AC}, + {0xE0100, 0xE01EF}, {0xF0000, 0xFFFFD}, {0x100000, 0x10FFFD} +}; + + +/* Unassigned characters. */ +static const struct widechar_range widechar_unassigned_table[] = { + {0x00378, 0x00379}, {0x00380, 0x00383}, {0x0038B, 0x0038B}, + {0x0038D, 0x0038D}, {0x003A2, 0x003A2}, {0x00530, 0x00530}, + {0x00557, 0x00558}, {0x0058B, 0x0058C}, {0x00590, 0x00590}, + {0x005C8, 0x005CF}, {0x005EB, 0x005EE}, {0x005F5, 0x005FF}, + {0x0061D, 0x0061D}, {0x0070E, 0x0070E}, {0x0074B, 0x0074C}, + {0x007B2, 0x007BF}, {0x007FB, 0x007FC}, {0x0082E, 0x0082F}, + {0x0083F, 0x0083F}, {0x0085C, 0x0085D}, {0x0085F, 0x0085F}, + {0x0086B, 0x0089F}, {0x008B5, 0x008B5}, {0x008BE, 0x008D2}, + {0x00984, 0x00984}, {0x0098D, 0x0098E}, {0x00991, 0x00992}, + {0x009A9, 0x009A9}, {0x009B1, 0x009B1}, {0x009B3, 0x009B5}, + {0x009BA, 0x009BB}, {0x009C5, 0x009C6}, {0x009C9, 0x009CA}, + {0x009CF, 0x009D6}, {0x009D8, 0x009DB}, {0x009DE, 0x009DE}, + {0x009E4, 0x009E5}, {0x009FF, 0x00A00}, {0x00A04, 0x00A04}, + {0x00A0B, 0x00A0E}, {0x00A11, 0x00A12}, {0x00A29, 0x00A29}, + {0x00A31, 0x00A31}, {0x00A34, 0x00A34}, {0x00A37, 0x00A37}, + {0x00A3A, 0x00A3B}, {0x00A3D, 0x00A3D}, {0x00A43, 0x00A46}, + {0x00A49, 0x00A4A}, {0x00A4E, 0x00A50}, {0x00A52, 0x00A58}, + {0x00A5D, 0x00A5D}, {0x00A5F, 0x00A65}, {0x00A77, 0x00A80}, + {0x00A84, 0x00A84}, {0x00A8E, 0x00A8E}, {0x00A92, 0x00A92}, + {0x00AA9, 0x00AA9}, {0x00AB1, 0x00AB1}, {0x00AB4, 0x00AB4}, + {0x00ABA, 0x00ABB}, {0x00AC6, 0x00AC6}, {0x00ACA, 0x00ACA}, + {0x00ACE, 0x00ACF}, {0x00AD1, 0x00ADF}, {0x00AE4, 0x00AE5}, + {0x00AF2, 0x00AF8}, {0x00B00, 0x00B00}, {0x00B04, 0x00B04}, + {0x00B0D, 0x00B0E}, {0x00B11, 0x00B12}, {0x00B29, 0x00B29}, + {0x00B31, 0x00B31}, {0x00B34, 0x00B34}, {0x00B3A, 0x00B3B}, + {0x00B45, 0x00B46}, {0x00B49, 0x00B4A}, {0x00B4E, 0x00B55}, + {0x00B58, 0x00B5B}, {0x00B5E, 0x00B5E}, {0x00B64, 0x00B65}, + {0x00B78, 0x00B81}, {0x00B84, 0x00B84}, {0x00B8B, 0x00B8D}, + {0x00B91, 0x00B91}, {0x00B96, 0x00B98}, {0x00B9B, 0x00B9B}, + {0x00B9D, 0x00B9D}, {0x00BA0, 0x00BA2}, {0x00BA5, 0x00BA7}, + {0x00BAB, 0x00BAD}, {0x00BBA, 0x00BBD}, {0x00BC3, 0x00BC5}, + {0x00BC9, 0x00BC9}, {0x00BCE, 0x00BCF}, {0x00BD1, 0x00BD6}, + {0x00BD8, 0x00BE5}, {0x00BFB, 0x00BFF}, {0x00C0D, 0x00C0D}, + {0x00C11, 0x00C11}, {0x00C29, 0x00C29}, {0x00C3A, 0x00C3C}, + {0x00C45, 0x00C45}, {0x00C49, 0x00C49}, {0x00C4E, 0x00C54}, + {0x00C57, 0x00C57}, {0x00C5B, 0x00C5F}, {0x00C64, 0x00C65}, + {0x00C70, 0x00C77}, {0x00C8D, 0x00C8D}, {0x00C91, 0x00C91}, + {0x00CA9, 0x00CA9}, {0x00CB4, 0x00CB4}, {0x00CBA, 0x00CBB}, + {0x00CC5, 0x00CC5}, {0x00CC9, 0x00CC9}, {0x00CCE, 0x00CD4}, + {0x00CD7, 0x00CDD}, {0x00CDF, 0x00CDF}, {0x00CE4, 0x00CE5}, + {0x00CF0, 0x00CF0}, {0x00CF3, 0x00CFF}, {0x00D04, 0x00D04}, + {0x00D0D, 0x00D0D}, {0x00D11, 0x00D11}, {0x00D45, 0x00D45}, + {0x00D49, 0x00D49}, {0x00D50, 0x00D53}, {0x00D64, 0x00D65}, + {0x00D80, 0x00D81}, {0x00D84, 0x00D84}, {0x00D97, 0x00D99}, + {0x00DB2, 0x00DB2}, {0x00DBC, 0x00DBC}, {0x00DBE, 0x00DBF}, + {0x00DC7, 0x00DC9}, {0x00DCB, 0x00DCE}, {0x00DD5, 0x00DD5}, + {0x00DD7, 0x00DD7}, {0x00DE0, 0x00DE5}, {0x00DF0, 0x00DF1}, + {0x00DF5, 0x00E00}, {0x00E3B, 0x00E3E}, {0x00E5C, 0x00E80}, + {0x00E83, 0x00E83}, {0x00E85, 0x00E86}, {0x00E89, 0x00E89}, + {0x00E8B, 0x00E8C}, {0x00E8E, 0x00E93}, {0x00E98, 0x00E98}, + {0x00EA0, 0x00EA0}, {0x00EA4, 0x00EA4}, {0x00EA6, 0x00EA6}, + {0x00EA8, 0x00EA9}, {0x00EAC, 0x00EAC}, {0x00EBA, 0x00EBA}, + {0x00EBE, 0x00EBF}, {0x00EC5, 0x00EC5}, {0x00EC7, 0x00EC7}, + {0x00ECE, 0x00ECF}, {0x00EDA, 0x00EDB}, {0x00EE0, 0x00EFF}, + {0x00F48, 0x00F48}, {0x00F6D, 0x00F70}, {0x00F98, 0x00F98}, + {0x00FBD, 0x00FBD}, {0x00FCD, 0x00FCD}, {0x00FDB, 0x00FFF}, + {0x010C6, 0x010C6}, {0x010C8, 0x010CC}, {0x010CE, 0x010CF}, + {0x01249, 0x01249}, {0x0124E, 0x0124F}, {0x01257, 0x01257}, + {0x01259, 0x01259}, {0x0125E, 0x0125F}, {0x01289, 0x01289}, + {0x0128E, 0x0128F}, {0x012B1, 0x012B1}, {0x012B6, 0x012B7}, + {0x012BF, 0x012BF}, {0x012C1, 0x012C1}, {0x012C6, 0x012C7}, + {0x012D7, 0x012D7}, {0x01311, 0x01311}, {0x01316, 0x01317}, + {0x0135B, 0x0135C}, {0x0137D, 0x0137F}, {0x0139A, 0x0139F}, + {0x013F6, 0x013F7}, {0x013FE, 0x013FF}, {0x0169D, 0x0169F}, + {0x016F9, 0x016FF}, {0x0170D, 0x0170D}, {0x01715, 0x0171F}, + {0x01737, 0x0173F}, {0x01754, 0x0175F}, {0x0176D, 0x0176D}, + {0x01771, 0x01771}, {0x01774, 0x0177F}, {0x017DE, 0x017DF}, + {0x017EA, 0x017EF}, {0x017FA, 0x017FF}, {0x0180F, 0x0180F}, + {0x0181A, 0x0181F}, {0x01879, 0x0187F}, {0x018AB, 0x018AF}, + {0x018F6, 0x018FF}, {0x0191F, 0x0191F}, {0x0192C, 0x0192F}, + {0x0193C, 0x0193F}, {0x01941, 0x01943}, {0x0196E, 0x0196F}, + {0x01975, 0x0197F}, {0x019AC, 0x019AF}, {0x019CA, 0x019CF}, + {0x019DB, 0x019DD}, {0x01A1C, 0x01A1D}, {0x01A5F, 0x01A5F}, + {0x01A7D, 0x01A7E}, {0x01A8A, 0x01A8F}, {0x01A9A, 0x01A9F}, + {0x01AAE, 0x01AAF}, {0x01ABF, 0x01AFF}, {0x01B4C, 0x01B4F}, + {0x01B7D, 0x01B7F}, {0x01BF4, 0x01BFB}, {0x01C38, 0x01C3A}, + {0x01C4A, 0x01C4C}, {0x01C89, 0x01C8F}, {0x01CBB, 0x01CBC}, + {0x01CC8, 0x01CCF}, {0x01CFA, 0x01CFF}, {0x01DFA, 0x01DFA}, + {0x01F16, 0x01F17}, {0x01F1E, 0x01F1F}, {0x01F46, 0x01F47}, + {0x01F4E, 0x01F4F}, {0x01F58, 0x01F58}, {0x01F5A, 0x01F5A}, + {0x01F5C, 0x01F5C}, {0x01F5E, 0x01F5E}, {0x01F7E, 0x01F7F}, + {0x01FB5, 0x01FB5}, {0x01FC5, 0x01FC5}, {0x01FD4, 0x01FD5}, + {0x01FDC, 0x01FDC}, {0x01FF0, 0x01FF1}, {0x01FF5, 0x01FF5}, + {0x01FFF, 0x01FFF}, {0x02065, 0x02065}, {0x02072, 0x02073}, + {0x0208F, 0x0208F}, {0x0209D, 0x0209F}, {0x020C0, 0x020CF}, + {0x020F1, 0x020FF}, {0x0218C, 0x0218F}, {0x02427, 0x0243F}, + {0x0244B, 0x0245F}, {0x02B74, 0x02B75}, {0x02B96, 0x02B97}, + {0x02BC9, 0x02BC9}, {0x02BFF, 0x02BFF}, {0x02C2F, 0x02C2F}, + {0x02C5F, 0x02C5F}, {0x02CF4, 0x02CF8}, {0x02D26, 0x02D26}, + {0x02D28, 0x02D2C}, {0x02D2E, 0x02D2F}, {0x02D68, 0x02D6E}, + {0x02D71, 0x02D7E}, {0x02D97, 0x02D9F}, {0x02DA7, 0x02DA7}, + {0x02DAF, 0x02DAF}, {0x02DB7, 0x02DB7}, {0x02DBF, 0x02DBF}, + {0x02DC7, 0x02DC7}, {0x02DCF, 0x02DCF}, {0x02DD7, 0x02DD7}, + {0x02DDF, 0x02DDF}, {0x02E4F, 0x02E7F}, {0x02E9A, 0x02E9A}, + {0x02EF4, 0x02EFF}, {0x02FD6, 0x02FEF}, {0x02FFC, 0x02FFF}, + {0x03040, 0x03040}, {0x03097, 0x03098}, {0x03100, 0x03104}, + {0x03130, 0x03130}, {0x0318F, 0x0318F}, {0x031BB, 0x031BF}, + {0x031E4, 0x031EF}, {0x0321F, 0x0321F}, {0x032FF, 0x032FF}, + {0x03401, 0x04DB4}, {0x04DB6, 0x04DBF}, {0x04E01, 0x09FEE}, + {0x09FF0, 0x09FFF}, {0x0A48D, 0x0A48F}, {0x0A4C7, 0x0A4CF}, + {0x0A62C, 0x0A63F}, {0x0A6F8, 0x0A6FF}, {0x0A7BA, 0x0A7F6}, + {0x0A82C, 0x0A82F}, {0x0A83A, 0x0A83F}, {0x0A878, 0x0A87F}, + {0x0A8C6, 0x0A8CD}, {0x0A8DA, 0x0A8DF}, {0x0A954, 0x0A95E}, + {0x0A97D, 0x0A97F}, {0x0A9CE, 0x0A9CE}, {0x0A9DA, 0x0A9DD}, + {0x0A9FF, 0x0A9FF}, {0x0AA37, 0x0AA3F}, {0x0AA4E, 0x0AA4F}, + {0x0AA5A, 0x0AA5B}, {0x0AAC3, 0x0AADA}, {0x0AAF7, 0x0AB00}, + {0x0AB07, 0x0AB08}, {0x0AB0F, 0x0AB10}, {0x0AB17, 0x0AB1F}, + {0x0AB27, 0x0AB27}, {0x0AB2F, 0x0AB2F}, {0x0AB66, 0x0AB6F}, + {0x0ABEE, 0x0ABEF}, {0x0ABFA, 0x0ABFF}, {0x0AC01, 0x0D7A2}, + {0x0D7A4, 0x0D7AF}, {0x0D7C7, 0x0D7CA}, {0x0D7FC, 0x0D7FF}, + {0x0FA6E, 0x0FA6F}, {0x0FADA, 0x0FAFF}, {0x0FB07, 0x0FB12}, + {0x0FB18, 0x0FB1C}, {0x0FB37, 0x0FB37}, {0x0FB3D, 0x0FB3D}, + {0x0FB3F, 0x0FB3F}, {0x0FB42, 0x0FB42}, {0x0FB45, 0x0FB45}, + {0x0FBC2, 0x0FBD2}, {0x0FD40, 0x0FD4F}, {0x0FD90, 0x0FD91}, + {0x0FDC8, 0x0FDEF}, {0x0FDFE, 0x0FDFF}, {0x0FE1A, 0x0FE1F}, + {0x0FE53, 0x0FE53}, {0x0FE67, 0x0FE67}, {0x0FE6C, 0x0FE6F}, + {0x0FE75, 0x0FE75}, {0x0FEFD, 0x0FEFE}, {0x0FF00, 0x0FF00}, + {0x0FFBF, 0x0FFC1}, {0x0FFC8, 0x0FFC9}, {0x0FFD0, 0x0FFD1}, + {0x0FFD8, 0x0FFD9}, {0x0FFDD, 0x0FFDF}, {0x0FFE7, 0x0FFE7}, + {0x0FFEF, 0x0FFF8}, {0x0FFFE, 0x0FFFF}, {0x1000C, 0x1000C}, + {0x10027, 0x10027}, {0x1003B, 0x1003B}, {0x1003E, 0x1003E}, + {0x1004E, 0x1004F}, {0x1005E, 0x1007F}, {0x100FB, 0x100FF}, + {0x10103, 0x10106}, {0x10134, 0x10136}, {0x1018F, 0x1018F}, + {0x1019C, 0x1019F}, {0x101A1, 0x101CF}, {0x101FE, 0x1027F}, + {0x1029D, 0x1029F}, {0x102D1, 0x102DF}, {0x102FC, 0x102FF}, + {0x10324, 0x1032C}, {0x1034B, 0x1034F}, {0x1037B, 0x1037F}, + {0x1039E, 0x1039E}, {0x103C4, 0x103C7}, {0x103D6, 0x103FF}, + {0x1049E, 0x1049F}, {0x104AA, 0x104AF}, {0x104D4, 0x104D7}, + {0x104FC, 0x104FF}, {0x10528, 0x1052F}, {0x10564, 0x1056E}, + {0x10570, 0x105FF}, {0x10737, 0x1073F}, {0x10756, 0x1075F}, + {0x10768, 0x107FF}, {0x10806, 0x10807}, {0x10809, 0x10809}, + {0x10836, 0x10836}, {0x10839, 0x1083B}, {0x1083D, 0x1083E}, + {0x10856, 0x10856}, {0x1089F, 0x108A6}, {0x108B0, 0x108DF}, + {0x108F3, 0x108F3}, {0x108F6, 0x108FA}, {0x1091C, 0x1091E}, + {0x1093A, 0x1093E}, {0x10940, 0x1097F}, {0x109B8, 0x109BB}, + {0x109D0, 0x109D1}, {0x10A04, 0x10A04}, {0x10A07, 0x10A0B}, + {0x10A14, 0x10A14}, {0x10A18, 0x10A18}, {0x10A36, 0x10A37}, + {0x10A3B, 0x10A3E}, {0x10A49, 0x10A4F}, {0x10A59, 0x10A5F}, + {0x10AA0, 0x10ABF}, {0x10AE7, 0x10AEA}, {0x10AF7, 0x10AFF}, + {0x10B36, 0x10B38}, {0x10B56, 0x10B57}, {0x10B73, 0x10B77}, + {0x10B92, 0x10B98}, {0x10B9D, 0x10BA8}, {0x10BB0, 0x10BFF}, + {0x10C49, 0x10C7F}, {0x10CB3, 0x10CBF}, {0x10CF3, 0x10CF9}, + {0x10D28, 0x10D2F}, {0x10D3A, 0x10E5F}, {0x10E7F, 0x10EFF}, + {0x10F28, 0x10F2F}, {0x10F5A, 0x10FFF}, {0x1104E, 0x11051}, + {0x11070, 0x1107E}, {0x110C2, 0x110CC}, {0x110CE, 0x110CF}, + {0x110E9, 0x110EF}, {0x110FA, 0x110FF}, {0x11135, 0x11135}, + {0x11147, 0x1114F}, {0x11177, 0x1117F}, {0x111CE, 0x111CF}, + {0x111E0, 0x111E0}, {0x111F5, 0x111FF}, {0x11212, 0x11212}, + {0x1123F, 0x1127F}, {0x11287, 0x11287}, {0x11289, 0x11289}, + {0x1128E, 0x1128E}, {0x1129E, 0x1129E}, {0x112AA, 0x112AF}, + {0x112EB, 0x112EF}, {0x112FA, 0x112FF}, {0x11304, 0x11304}, + {0x1130D, 0x1130E}, {0x11311, 0x11312}, {0x11329, 0x11329}, + {0x11331, 0x11331}, {0x11334, 0x11334}, {0x1133A, 0x1133A}, + {0x11345, 0x11346}, {0x11349, 0x1134A}, {0x1134E, 0x1134F}, + {0x11351, 0x11356}, {0x11358, 0x1135C}, {0x11364, 0x11365}, + {0x1136D, 0x1136F}, {0x11375, 0x113FF}, {0x1145A, 0x1145A}, + {0x1145C, 0x1145C}, {0x1145F, 0x1147F}, {0x114C8, 0x114CF}, + {0x114DA, 0x1157F}, {0x115B6, 0x115B7}, {0x115DE, 0x115FF}, + {0x11645, 0x1164F}, {0x1165A, 0x1165F}, {0x1166D, 0x1167F}, + {0x116B8, 0x116BF}, {0x116CA, 0x116FF}, {0x1171B, 0x1171C}, + {0x1172C, 0x1172F}, {0x11740, 0x117FF}, {0x1183C, 0x1189F}, + {0x118F3, 0x118FE}, {0x11900, 0x119FF}, {0x11A48, 0x11A4F}, + {0x11A84, 0x11A85}, {0x11AA3, 0x11ABF}, {0x11AF9, 0x11BFF}, + {0x11C09, 0x11C09}, {0x11C37, 0x11C37}, {0x11C46, 0x11C4F}, + {0x11C6D, 0x11C6F}, {0x11C90, 0x11C91}, {0x11CA8, 0x11CA8}, + {0x11CB7, 0x11CFF}, {0x11D07, 0x11D07}, {0x11D0A, 0x11D0A}, + {0x11D37, 0x11D39}, {0x11D3B, 0x11D3B}, {0x11D3E, 0x11D3E}, + {0x11D48, 0x11D4F}, {0x11D5A, 0x11D5F}, {0x11D66, 0x11D66}, + {0x11D69, 0x11D69}, {0x11D8F, 0x11D8F}, {0x11D92, 0x11D92}, + {0x11D99, 0x11D9F}, {0x11DAA, 0x11EDF}, {0x11EF9, 0x11FFF}, + {0x1239A, 0x123FF}, {0x1246F, 0x1246F}, {0x12475, 0x1247F}, + {0x12544, 0x12FFF}, {0x1342F, 0x143FF}, {0x14647, 0x167FF}, + {0x16A39, 0x16A3F}, {0x16A5F, 0x16A5F}, {0x16A6A, 0x16A6D}, + {0x16A70, 0x16ACF}, {0x16AEE, 0x16AEF}, {0x16AF6, 0x16AFF}, + {0x16B46, 0x16B4F}, {0x16B5A, 0x16B5A}, {0x16B62, 0x16B62}, + {0x16B78, 0x16B7C}, {0x16B90, 0x16E3F}, {0x16E9B, 0x16EFF}, + {0x16F45, 0x16F4F}, {0x16F7F, 0x16F8E}, {0x16FA0, 0x16FDF}, + {0x16FE2, 0x16FFF}, {0x17001, 0x187F0}, {0x187F2, 0x187FF}, + {0x18AF3, 0x1AFFF}, {0x1B11F, 0x1B16F}, {0x1B2FC, 0x1BBFF}, + {0x1BC6B, 0x1BC6F}, {0x1BC7D, 0x1BC7F}, {0x1BC89, 0x1BC8F}, + {0x1BC9A, 0x1BC9B}, {0x1BCA4, 0x1CFFF}, {0x1D0F6, 0x1D0FF}, + {0x1D127, 0x1D128}, {0x1D1E9, 0x1D1FF}, {0x1D246, 0x1D2DF}, + {0x1D2F4, 0x1D2FF}, {0x1D357, 0x1D35F}, {0x1D379, 0x1D3FF}, + {0x1D455, 0x1D455}, {0x1D49D, 0x1D49D}, {0x1D4A0, 0x1D4A1}, + {0x1D4A3, 0x1D4A4}, {0x1D4A7, 0x1D4A8}, {0x1D4AD, 0x1D4AD}, + {0x1D4BA, 0x1D4BA}, {0x1D4BC, 0x1D4BC}, {0x1D4C4, 0x1D4C4}, + {0x1D506, 0x1D506}, {0x1D50B, 0x1D50C}, {0x1D515, 0x1D515}, + {0x1D51D, 0x1D51D}, {0x1D53A, 0x1D53A}, {0x1D53F, 0x1D53F}, + {0x1D545, 0x1D545}, {0x1D547, 0x1D549}, {0x1D551, 0x1D551}, + {0x1D6A6, 0x1D6A7}, {0x1D7CC, 0x1D7CD}, {0x1DA8C, 0x1DA9A}, + {0x1DAA0, 0x1DAA0}, {0x1DAB0, 0x1DFFF}, {0x1E007, 0x1E007}, + {0x1E019, 0x1E01A}, {0x1E022, 0x1E022}, {0x1E025, 0x1E025}, + {0x1E02B, 0x1E7FF}, {0x1E8C5, 0x1E8C6}, {0x1E8D7, 0x1E8FF}, + {0x1E94B, 0x1E94F}, {0x1E95A, 0x1E95D}, {0x1E960, 0x1EC70}, + {0x1ECB5, 0x1EDFF}, {0x1EE04, 0x1EE04}, {0x1EE20, 0x1EE20}, + {0x1EE23, 0x1EE23}, {0x1EE25, 0x1EE26}, {0x1EE28, 0x1EE28}, + {0x1EE33, 0x1EE33}, {0x1EE38, 0x1EE38}, {0x1EE3A, 0x1EE3A}, + {0x1EE3C, 0x1EE41}, {0x1EE43, 0x1EE46}, {0x1EE48, 0x1EE48}, + {0x1EE4A, 0x1EE4A}, {0x1EE4C, 0x1EE4C}, {0x1EE50, 0x1EE50}, + {0x1EE53, 0x1EE53}, {0x1EE55, 0x1EE56}, {0x1EE58, 0x1EE58}, + {0x1EE5A, 0x1EE5A}, {0x1EE5C, 0x1EE5C}, {0x1EE5E, 0x1EE5E}, + {0x1EE60, 0x1EE60}, {0x1EE63, 0x1EE63}, {0x1EE65, 0x1EE66}, + {0x1EE6B, 0x1EE6B}, {0x1EE73, 0x1EE73}, {0x1EE78, 0x1EE78}, + {0x1EE7D, 0x1EE7D}, {0x1EE7F, 0x1EE7F}, {0x1EE8A, 0x1EE8A}, + {0x1EE9C, 0x1EEA0}, {0x1EEA4, 0x1EEA4}, {0x1EEAA, 0x1EEAA}, + {0x1EEBC, 0x1EEEF}, {0x1EEF2, 0x1EFFF}, {0x1F02C, 0x1F02F}, + {0x1F094, 0x1F09F}, {0x1F0AF, 0x1F0B0}, {0x1F0C0, 0x1F0C0}, + {0x1F0D0, 0x1F0D0}, {0x1F0F6, 0x1F0FF}, {0x1F10D, 0x1F10F}, + {0x1F16C, 0x1F16F}, {0x1F1AD, 0x1F1E5}, {0x1F203, 0x1F20F}, + {0x1F23C, 0x1F23F}, {0x1F249, 0x1F24F}, {0x1F252, 0x1F25F}, + {0x1F266, 0x1F2FF}, {0x1F6D5, 0x1F6DF}, {0x1F6ED, 0x1F6EF}, + {0x1F6FA, 0x1F6FF}, {0x1F774, 0x1F77F}, {0x1F7D9, 0x1F7FF}, + {0x1F80C, 0x1F80F}, {0x1F848, 0x1F84F}, {0x1F85A, 0x1F85F}, + {0x1F888, 0x1F88F}, {0x1F8AE, 0x1F8FF}, {0x1F90C, 0x1F90F}, + {0x1F93F, 0x1F93F}, {0x1F971, 0x1F972}, {0x1F977, 0x1F979}, + {0x1F97B, 0x1F97B}, {0x1F9A3, 0x1F9AF}, {0x1F9BA, 0x1F9BF}, + {0x1F9C3, 0x1F9CF}, {0x1FA00, 0x1FA5F}, {0x1FA6E, 0x1FFFF}, + {0x20001, 0x2A6D5}, {0x2A6D7, 0x2A6FF}, {0x2A701, 0x2B733}, + {0x2B735, 0x2B73F}, {0x2B741, 0x2B81C}, {0x2B81E, 0x2B81F}, + {0x2B821, 0x2CEA0}, {0x2CEA2, 0x2CEAF}, {0x2CEB1, 0x2EBDF}, + {0x2EBE1, 0x2F7FF}, {0x2FA1E, 0xE0000}, {0xE0002, 0xE001F}, + {0xE0080, 0xE00FF}, {0xE01F0, 0xEFFFF}, {0xFFFFE, 0xFFFFF}, + {0x10FFFE, 0x110000} +}; + +/* Characters that were widened from with 1 to 2 in Unicode 9. */ +static const struct widechar_range widechar_widened_table[] = { + {0x1F004, 0x1F004}, {0x1F0CF, 0x1F0CF}, {0x1F170, 0x1F171}, + {0x1F17E, 0x1F17F}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A}, + {0x1F1E6, 0x1F1FF}, {0x1F201, 0x1F202}, {0x1F21A, 0x1F21A}, + {0x1F22F, 0x1F22F}, {0x1F232, 0x1F23A}, {0x1F250, 0x1F251}, + {0x1F300, 0x1F321}, {0x1F324, 0x1F393}, {0x1F396, 0x1F397}, + {0x1F399, 0x1F39B}, {0x1F39E, 0x1F3F0}, {0x1F3F3, 0x1F3F5}, + {0x1F3F7, 0x1F4FD}, {0x1F4FF, 0x1F53D}, {0x1F549, 0x1F54E}, + {0x1F550, 0x1F567}, {0x1F56F, 0x1F570}, {0x1F573, 0x1F579}, + {0x1F587, 0x1F587}, {0x1F58A, 0x1F58D}, {0x1F590, 0x1F590}, + {0x1F595, 0x1F596}, {0x1F5A5, 0x1F5A5}, {0x1F5A8, 0x1F5A8}, + {0x1F5B1, 0x1F5B2}, {0x1F5BC, 0x1F5BC}, {0x1F5C2, 0x1F5C4}, + {0x1F5D1, 0x1F5D3}, {0x1F5DC, 0x1F5DE}, {0x1F5E1, 0x1F5E1}, + {0x1F5E3, 0x1F5E3}, {0x1F5E8, 0x1F5E8}, {0x1F5EF, 0x1F5EF}, + {0x1F5F3, 0x1F5F3}, {0x1F5FA, 0x1F64F}, {0x1F680, 0x1F6C5}, + {0x1F6CB, 0x1F6D0}, {0x1F6E0, 0x1F6E5}, {0x1F6E9, 0x1F6E9}, + {0x1F6EB, 0x1F6EC}, {0x1F6F0, 0x1F6F0}, {0x1F6F3, 0x1F6F3}, + {0x1F910, 0x1F918}, {0x1F980, 0x1F984}, {0x1F9C0, 0x1F9C0} +}; + +template +bool widechar_in_table(const Collection &arr, int32_t c) { + auto where = std::lower_bound(std::begin(arr), std::end(arr), c, + [](widechar_range p, wchar_t c) { return p.hi < c; }); + return where != std::end(arr) && where->lo <= c; +} + +/* Return the width of character c, or a special negative value. */ +int widechar_wcwidth(wchar_t c) { + if (widechar_in_table(widechar_private_table, c)) + return widechar_private_use; + if (widechar_in_table(widechar_nonprint_table, c)) + return widechar_nonprint; + if (widechar_in_table(widechar_combining_table, c)) + return widechar_combining; + if (widechar_in_table(widechar_doublewide_table, c)) + return 2; + if (widechar_in_table(widechar_ambiguous_table, c)) + return widechar_ambiguous; + if (widechar_in_table(widechar_unassigned_table, c)) + return widechar_unassigned; + if (widechar_in_table(widechar_widened_table, c)) + return widechar_widened_in_9; + return 1; +} + +} // namespace +#endif // WIDECHAR_WIDTH_H