mirror of
https://github.com/aristocratos/btop.git
synced 2026-02-07 04:42:28 -05:00
Update widechar detection and fix replace_ascii_control() removing wide characters
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
/**
|
||||
* widechar_width.h, generated on 2022-02-11.
|
||||
* widechar_width.h for Unicode 17.0.0
|
||||
* See https://github.com/ridiculousfish/widecharwidth/
|
||||
*
|
||||
* SHA1 file hashes:
|
||||
* UnicodeData.txt: 8a5c26bfb27df8cfab23cf2c34c62d8d3075ae4d
|
||||
* EastAsianWidth.txt: 8ec36ccac3852bf0c2f02e37c6151551cd14db72
|
||||
* emoji-data.txt: 3f0ec08c001c4bc6df0b07d01068fc73808bfb4c
|
||||
* (
|
||||
* the hashes for generate.py and the template are git object hashes,
|
||||
* use `git log --all --find-object=<hash>` in the widecharwidth repository
|
||||
* to see which commit they correspond to,
|
||||
* or run `git hash-object` on the file to compare.
|
||||
* The other hashes are simple `sha1sum` style hashes.
|
||||
* )
|
||||
*
|
||||
* generate.py: b35da43f176cc0d5880c67356ebb064048c5bac4
|
||||
* template.js: 1249763c5b7c1e308aeb4ca64f1e15bce1fab9b3
|
||||
* UnicodeData.txt: 50dffef1b7d1f97b72e4c2adceb9b2245f0f34ba
|
||||
* EastAsianWidth.txt: 2cadc5034b6206ad84b75898a1d4186bb38fc12b
|
||||
* emoji-data.txt: 3d123e12f70f63e609c4281ce83dfdd9ac7443d2
|
||||
*/
|
||||
|
||||
#ifndef WIDECHAR_WIDTH_H
|
||||
@@ -16,7 +26,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace utf8 {
|
||||
namespace {
|
||||
|
||||
/* Special width values */
|
||||
enum {
|
||||
@@ -68,7 +78,7 @@ static const struct widechar_range widechar_nonprint_table[] = {
|
||||
{0x0FFF9, 0x0FFFB},
|
||||
{0x110BD, 0x110BD},
|
||||
{0x110CD, 0x110CD},
|
||||
{0x13430, 0x13438},
|
||||
{0x13430, 0x1343F},
|
||||
{0x1BCA0, 0x1BCA3},
|
||||
{0x1D173, 0x1D17A},
|
||||
{0xE0001, 0xE0001},
|
||||
@@ -101,7 +111,7 @@ static const struct widechar_range widechar_combining_table[] = {
|
||||
{0x00825, 0x00827},
|
||||
{0x00829, 0x0082D},
|
||||
{0x00859, 0x0085B},
|
||||
{0x00898, 0x0089F},
|
||||
{0x00897, 0x0089F},
|
||||
{0x008CA, 0x008E1},
|
||||
{0x008E3, 0x00903},
|
||||
{0x0093A, 0x0093C},
|
||||
@@ -157,6 +167,7 @@ static const struct widechar_range widechar_combining_table[] = {
|
||||
{0x00CCA, 0x00CCD},
|
||||
{0x00CD5, 0x00CD6},
|
||||
{0x00CE2, 0x00CE3},
|
||||
{0x00CF3, 0x00CF3},
|
||||
{0x00D00, 0x00D03},
|
||||
{0x00D3B, 0x00D3C},
|
||||
{0x00D3E, 0x00D44},
|
||||
@@ -175,7 +186,7 @@ static const struct widechar_range widechar_combining_table[] = {
|
||||
{0x00E47, 0x00E4E},
|
||||
{0x00EB1, 0x00EB1},
|
||||
{0x00EB4, 0x00EBC},
|
||||
{0x00EC8, 0x00ECD},
|
||||
{0x00EC8, 0x00ECE},
|
||||
{0x00F18, 0x00F19},
|
||||
{0x00F35, 0x00F35},
|
||||
{0x00F37, 0x00F37},
|
||||
@@ -212,7 +223,8 @@ static const struct widechar_range widechar_combining_table[] = {
|
||||
{0x01A55, 0x01A5E},
|
||||
{0x01A60, 0x01A7C},
|
||||
{0x01A7F, 0x01A7F},
|
||||
{0x01AB0, 0x01ACE},
|
||||
{0x01AB0, 0x01ADD},
|
||||
{0x01AE0, 0x01AEB},
|
||||
{0x01B00, 0x01B04},
|
||||
{0x01B34, 0x01B44},
|
||||
{0x01B6B, 0x01B73},
|
||||
@@ -276,7 +288,9 @@ static const struct widechar_range widechar_combining_table[] = {
|
||||
{0x10A3F, 0x10A3F},
|
||||
{0x10AE5, 0x10AE6},
|
||||
{0x10D24, 0x10D27},
|
||||
{0x10D69, 0x10D6D},
|
||||
{0x10EAB, 0x10EAC},
|
||||
{0x10EFA, 0x10EFF},
|
||||
{0x10F46, 0x10F50},
|
||||
{0x10F82, 0x10F85},
|
||||
{0x11000, 0x11002},
|
||||
@@ -296,6 +310,7 @@ static const struct widechar_range widechar_combining_table[] = {
|
||||
{0x111CE, 0x111CF},
|
||||
{0x1122C, 0x11237},
|
||||
{0x1123E, 0x1123E},
|
||||
{0x11241, 0x11241},
|
||||
{0x112DF, 0x112EA},
|
||||
{0x11300, 0x11303},
|
||||
{0x1133B, 0x1133C},
|
||||
@@ -306,6 +321,13 @@ static const struct widechar_range widechar_combining_table[] = {
|
||||
{0x11362, 0x11363},
|
||||
{0x11366, 0x1136C},
|
||||
{0x11370, 0x11374},
|
||||
{0x113B8, 0x113C0},
|
||||
{0x113C2, 0x113C2},
|
||||
{0x113C5, 0x113C5},
|
||||
{0x113C7, 0x113CA},
|
||||
{0x113CC, 0x113D0},
|
||||
{0x113D2, 0x113D2},
|
||||
{0x113E1, 0x113E2},
|
||||
{0x11435, 0x11446},
|
||||
{0x1145E, 0x1145E},
|
||||
{0x114B0, 0x114C3},
|
||||
@@ -330,6 +352,7 @@ static const struct widechar_range widechar_combining_table[] = {
|
||||
{0x11A47, 0x11A47},
|
||||
{0x11A51, 0x11A5B},
|
||||
{0x11A8A, 0x11A99},
|
||||
{0x11B60, 0x11B67},
|
||||
{0x11C2F, 0x11C36},
|
||||
{0x11C38, 0x11C3F},
|
||||
{0x11C92, 0x11CA7},
|
||||
@@ -343,6 +366,14 @@ static const struct widechar_range widechar_combining_table[] = {
|
||||
{0x11D90, 0x11D91},
|
||||
{0x11D93, 0x11D97},
|
||||
{0x11EF3, 0x11EF6},
|
||||
{0x11F00, 0x11F01},
|
||||
{0x11F03, 0x11F03},
|
||||
{0x11F34, 0x11F3A},
|
||||
{0x11F3E, 0x11F42},
|
||||
{0x11F5A, 0x11F5A},
|
||||
{0x13440, 0x13440},
|
||||
{0x13447, 0x13455},
|
||||
{0x1611E, 0x1612F},
|
||||
{0x16AF0, 0x16AF4},
|
||||
{0x16B30, 0x16B36},
|
||||
{0x16F4F, 0x16F4F},
|
||||
@@ -370,9 +401,16 @@ static const struct widechar_range widechar_combining_table[] = {
|
||||
{0x1E01B, 0x1E021},
|
||||
{0x1E023, 0x1E024},
|
||||
{0x1E026, 0x1E02A},
|
||||
{0x1E08F, 0x1E08F},
|
||||
{0x1E130, 0x1E136},
|
||||
{0x1E2AE, 0x1E2AE},
|
||||
{0x1E2EC, 0x1E2EF},
|
||||
{0x1E4EC, 0x1E4EF},
|
||||
{0x1E5EE, 0x1E5EF},
|
||||
{0x1E6E3, 0x1E6E3},
|
||||
{0x1E6E6, 0x1E6E6},
|
||||
{0x1E6EE, 0x1E6EF},
|
||||
{0x1E6F5, 0x1E6F5},
|
||||
{0x1E8D0, 0x1E8D6},
|
||||
{0x1E944, 0x1E94A},
|
||||
{0xE0100, 0xE01EF}
|
||||
@@ -388,20 +426,20 @@ static const struct widechar_range widechar_combiningletters_table[] = {
|
||||
static const struct widechar_range widechar_doublewide_table[] = {
|
||||
{0x01100, 0x0115F},
|
||||
{0x02329, 0x0232A},
|
||||
{0x02630, 0x02637},
|
||||
{0x0268A, 0x0268F},
|
||||
{0x02E80, 0x02E99},
|
||||
{0x02E9B, 0x02EF3},
|
||||
{0x02F00, 0x02FD5},
|
||||
{0x02FF0, 0x02FFB},
|
||||
{0x03000, 0x0303E},
|
||||
{0x02FF0, 0x0303E},
|
||||
{0x03041, 0x03096},
|
||||
{0x03099, 0x030FF},
|
||||
{0x03105, 0x0312F},
|
||||
{0x03131, 0x0318E},
|
||||
{0x03190, 0x031E3},
|
||||
{0x031F0, 0x0321E},
|
||||
{0x03190, 0x031E5},
|
||||
{0x031EF, 0x0321E},
|
||||
{0x03220, 0x03247},
|
||||
{0x03250, 0x04DBF},
|
||||
{0x04E00, 0x0A48C},
|
||||
{0x03250, 0x0A48C},
|
||||
{0x0A490, 0x0A4C6},
|
||||
{0x0A960, 0x0A97C},
|
||||
{0x0AC00, 0x0D7A3},
|
||||
@@ -413,17 +451,21 @@ static const struct widechar_range widechar_doublewide_table[] = {
|
||||
{0x0FF01, 0x0FF60},
|
||||
{0x0FFE0, 0x0FFE6},
|
||||
{0x16FE0, 0x16FE4},
|
||||
{0x16FF0, 0x16FF1},
|
||||
{0x17000, 0x187F7},
|
||||
{0x18800, 0x18CD5},
|
||||
{0x18D00, 0x18D08},
|
||||
{0x16FF0, 0x16FF6},
|
||||
{0x17000, 0x18CD5},
|
||||
{0x18CFF, 0x18D1E},
|
||||
{0x18D80, 0x18DF2},
|
||||
{0x1AFF0, 0x1AFF3},
|
||||
{0x1AFF5, 0x1AFFB},
|
||||
{0x1AFFD, 0x1AFFE},
|
||||
{0x1B000, 0x1B122},
|
||||
{0x1B132, 0x1B132},
|
||||
{0x1B150, 0x1B152},
|
||||
{0x1B155, 0x1B155},
|
||||
{0x1B164, 0x1B167},
|
||||
{0x1B170, 0x1B2FB},
|
||||
{0x1D300, 0x1D356},
|
||||
{0x1D360, 0x1D376},
|
||||
{0x1F200, 0x1F200},
|
||||
{0x1F202, 0x1F202},
|
||||
{0x1F210, 0x1F219},
|
||||
@@ -436,8 +478,8 @@ static const struct widechar_range widechar_doublewide_table[] = {
|
||||
{0x1F57A, 0x1F57A},
|
||||
{0x1F5A4, 0x1F5A4},
|
||||
{0x1F6D1, 0x1F6D2},
|
||||
{0x1F6D5, 0x1F6D7},
|
||||
{0x1F6DD, 0x1F6DF},
|
||||
{0x1F6D5, 0x1F6D8},
|
||||
{0x1F6DC, 0x1F6DF},
|
||||
{0x1F6F4, 0x1F6FC},
|
||||
{0x1F7E0, 0x1F7EB},
|
||||
{0x1F7F0, 0x1F7F0},
|
||||
@@ -447,15 +489,13 @@ static const struct widechar_range widechar_doublewide_table[] = {
|
||||
{0x1F947, 0x1F97F},
|
||||
{0x1F985, 0x1F9BF},
|
||||
{0x1F9C1, 0x1F9FF},
|
||||
{0x1FA70, 0x1FA74},
|
||||
{0x1FA78, 0x1FA7C},
|
||||
{0x1FA80, 0x1FA86},
|
||||
{0x1FA90, 0x1FAAC},
|
||||
{0x1FAB0, 0x1FABA},
|
||||
{0x1FAC0, 0x1FAC5},
|
||||
{0x1FAD0, 0x1FAD9},
|
||||
{0x1FAE0, 0x1FAE7},
|
||||
{0x1FAF0, 0x1FAF6},
|
||||
{0x1FA70, 0x1FA7C},
|
||||
{0x1FA80, 0x1FA8A},
|
||||
{0x1FA8E, 0x1FAC6},
|
||||
{0x1FAC8, 0x1FAC8},
|
||||
{0x1FACD, 0x1FADC},
|
||||
{0x1FADF, 0x1FAEA},
|
||||
{0x1FAEF, 0x1FAF8},
|
||||
{0x20000, 0x2FFFD},
|
||||
{0x30000, 0x3FFFD}
|
||||
};
|
||||
@@ -666,8 +706,7 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x0085C, 0x0085D},
|
||||
{0x0085F, 0x0085F},
|
||||
{0x0086B, 0x0086F},
|
||||
{0x0088F, 0x0088F},
|
||||
{0x00892, 0x00897},
|
||||
{0x00892, 0x00896},
|
||||
{0x00984, 0x00984},
|
||||
{0x0098D, 0x0098E},
|
||||
{0x00991, 0x00992},
|
||||
@@ -750,7 +789,7 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x00C49, 0x00C49},
|
||||
{0x00C4E, 0x00C54},
|
||||
{0x00C57, 0x00C57},
|
||||
{0x00C5B, 0x00C5C},
|
||||
{0x00C5B, 0x00C5B},
|
||||
{0x00C5E, 0x00C5F},
|
||||
{0x00C64, 0x00C65},
|
||||
{0x00C70, 0x00C76},
|
||||
@@ -762,11 +801,11 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x00CC5, 0x00CC5},
|
||||
{0x00CC9, 0x00CC9},
|
||||
{0x00CCE, 0x00CD4},
|
||||
{0x00CD7, 0x00CDC},
|
||||
{0x00CD7, 0x00CDB},
|
||||
{0x00CDF, 0x00CDF},
|
||||
{0x00CE4, 0x00CE5},
|
||||
{0x00CF0, 0x00CF0},
|
||||
{0x00CF3, 0x00CFF},
|
||||
{0x00CF4, 0x00CFF},
|
||||
{0x00D0D, 0x00D0D},
|
||||
{0x00D11, 0x00D11},
|
||||
{0x00D45, 0x00D45},
|
||||
@@ -796,7 +835,7 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x00EBE, 0x00EBF},
|
||||
{0x00EC5, 0x00EC5},
|
||||
{0x00EC7, 0x00EC7},
|
||||
{0x00ECE, 0x00ECF},
|
||||
{0x00ECF, 0x00ECF},
|
||||
{0x00EDA, 0x00EDB},
|
||||
{0x00EE0, 0x00EFF},
|
||||
{0x00F48, 0x00F48},
|
||||
@@ -858,13 +897,13 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x01A8A, 0x01A8F},
|
||||
{0x01A9A, 0x01A9F},
|
||||
{0x01AAE, 0x01AAF},
|
||||
{0x01ACF, 0x01AFF},
|
||||
{0x01B4D, 0x01B4F},
|
||||
{0x01B7F, 0x01B7F},
|
||||
{0x01ADE, 0x01ADF},
|
||||
{0x01AEC, 0x01AFF},
|
||||
{0x01B4D, 0x01B4D},
|
||||
{0x01BF4, 0x01BFB},
|
||||
{0x01C38, 0x01C3A},
|
||||
{0x01C4A, 0x01C4C},
|
||||
{0x01C89, 0x01C8F},
|
||||
{0x01C8B, 0x01C8F},
|
||||
{0x01CBB, 0x01CBC},
|
||||
{0x01CC8, 0x01CCF},
|
||||
{0x01CFB, 0x01CFF},
|
||||
@@ -888,13 +927,12 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x02072, 0x02073},
|
||||
{0x0208F, 0x0208F},
|
||||
{0x0209D, 0x0209F},
|
||||
{0x020C1, 0x020CF},
|
||||
{0x020C2, 0x020CF},
|
||||
{0x020F1, 0x020FF},
|
||||
{0x0218C, 0x0218F},
|
||||
{0x02427, 0x0243F},
|
||||
{0x0242A, 0x0243F},
|
||||
{0x0244B, 0x0245F},
|
||||
{0x02B74, 0x02B75},
|
||||
{0x02B96, 0x02B96},
|
||||
{0x02CF4, 0x02CF8},
|
||||
{0x02D26, 0x02D26},
|
||||
{0x02D28, 0x02D2C},
|
||||
@@ -914,13 +952,12 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x02E9A, 0x02E9A},
|
||||
{0x02EF4, 0x02EFF},
|
||||
{0x02FD6, 0x02FEF},
|
||||
{0x02FFC, 0x02FFF},
|
||||
{0x03040, 0x03040},
|
||||
{0x03097, 0x03098},
|
||||
{0x03100, 0x03104},
|
||||
{0x03130, 0x03130},
|
||||
{0x0318F, 0x0318F},
|
||||
{0x031E4, 0x031EF},
|
||||
{0x031E6, 0x031EE},
|
||||
{0x0321F, 0x0321F},
|
||||
{0x03401, 0x04DBE},
|
||||
{0x04E01, 0x09FFE},
|
||||
@@ -928,10 +965,7 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x0A4C7, 0x0A4CF},
|
||||
{0x0A62C, 0x0A63F},
|
||||
{0x0A6F8, 0x0A6FF},
|
||||
{0x0A7CB, 0x0A7CF},
|
||||
{0x0A7D2, 0x0A7D2},
|
||||
{0x0A7D4, 0x0A7D4},
|
||||
{0x0A7DA, 0x0A7F1},
|
||||
{0x0A7DD, 0x0A7F0},
|
||||
{0x0A82D, 0x0A82F},
|
||||
{0x0A83A, 0x0A83F},
|
||||
{0x0A878, 0x0A87F},
|
||||
@@ -968,9 +1002,6 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x0FB3F, 0x0FB3F},
|
||||
{0x0FB42, 0x0FB42},
|
||||
{0x0FB45, 0x0FB45},
|
||||
{0x0FBC3, 0x0FBD2},
|
||||
{0x0FD90, 0x0FD91},
|
||||
{0x0FDC8, 0x0FDCE},
|
||||
{0x0FE1A, 0x0FE1F},
|
||||
{0x0FE53, 0x0FE53},
|
||||
{0x0FE67, 0x0FE67},
|
||||
@@ -1020,7 +1051,8 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x105A2, 0x105A2},
|
||||
{0x105B2, 0x105B2},
|
||||
{0x105BA, 0x105BA},
|
||||
{0x105BD, 0x105FF},
|
||||
{0x105BD, 0x105BF},
|
||||
{0x105F4, 0x105FF},
|
||||
{0x10737, 0x1073F},
|
||||
{0x10756, 0x1075F},
|
||||
{0x10768, 0x1077F},
|
||||
@@ -1039,7 +1071,7 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x108F6, 0x108FA},
|
||||
{0x1091C, 0x1091E},
|
||||
{0x1093A, 0x1093E},
|
||||
{0x10940, 0x1097F},
|
||||
{0x1095A, 0x1097F},
|
||||
{0x109B8, 0x109BB},
|
||||
{0x109D0, 0x109D1},
|
||||
{0x10A04, 0x10A04},
|
||||
@@ -1063,11 +1095,16 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x10CB3, 0x10CBF},
|
||||
{0x10CF3, 0x10CF9},
|
||||
{0x10D28, 0x10D2F},
|
||||
{0x10D3A, 0x10E5F},
|
||||
{0x10D3A, 0x10D3F},
|
||||
{0x10D66, 0x10D68},
|
||||
{0x10D86, 0x10D8D},
|
||||
{0x10D90, 0x10E5F},
|
||||
{0x10E7F, 0x10E7F},
|
||||
{0x10EAA, 0x10EAA},
|
||||
{0x10EAE, 0x10EAF},
|
||||
{0x10EB2, 0x10EFF},
|
||||
{0x10EB2, 0x10EC1},
|
||||
{0x10EC8, 0x10ECF},
|
||||
{0x10ED9, 0x10EF9},
|
||||
{0x10F28, 0x10F2F},
|
||||
{0x10F5A, 0x10F6F},
|
||||
{0x10F8A, 0x10FAF},
|
||||
@@ -1085,7 +1122,7 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x111E0, 0x111E0},
|
||||
{0x111F5, 0x111FF},
|
||||
{0x11212, 0x11212},
|
||||
{0x1123F, 0x1127F},
|
||||
{0x11242, 0x1127F},
|
||||
{0x11287, 0x11287},
|
||||
{0x11289, 0x11289},
|
||||
{0x1128E, 0x1128E},
|
||||
@@ -1107,7 +1144,18 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x11358, 0x1135C},
|
||||
{0x11364, 0x11365},
|
||||
{0x1136D, 0x1136F},
|
||||
{0x11375, 0x113FF},
|
||||
{0x11375, 0x1137F},
|
||||
{0x1138A, 0x1138A},
|
||||
{0x1138C, 0x1138D},
|
||||
{0x1138F, 0x1138F},
|
||||
{0x113B6, 0x113B6},
|
||||
{0x113C1, 0x113C1},
|
||||
{0x113C3, 0x113C4},
|
||||
{0x113C6, 0x113C6},
|
||||
{0x113CB, 0x113CB},
|
||||
{0x113D6, 0x113D6},
|
||||
{0x113D9, 0x113E0},
|
||||
{0x113E3, 0x113FF},
|
||||
{0x1145C, 0x1145C},
|
||||
{0x11462, 0x1147F},
|
||||
{0x114C8, 0x114CF},
|
||||
@@ -1118,7 +1166,8 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x1165A, 0x1165F},
|
||||
{0x1166D, 0x1167F},
|
||||
{0x116BA, 0x116BF},
|
||||
{0x116CA, 0x116FF},
|
||||
{0x116CA, 0x116CF},
|
||||
{0x116E4, 0x116FF},
|
||||
{0x1171B, 0x1171C},
|
||||
{0x1172C, 0x1172F},
|
||||
{0x11747, 0x117FF},
|
||||
@@ -1137,7 +1186,11 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x119E5, 0x119FF},
|
||||
{0x11A48, 0x11A4F},
|
||||
{0x11AA3, 0x11AAF},
|
||||
{0x11AF9, 0x11BFF},
|
||||
{0x11AF9, 0x11AFF},
|
||||
{0x11B0A, 0x11B5F},
|
||||
{0x11B68, 0x11BBF},
|
||||
{0x11BE2, 0x11BEF},
|
||||
{0x11BFA, 0x11BFF},
|
||||
{0x11C09, 0x11C09},
|
||||
{0x11C37, 0x11C37},
|
||||
{0x11C46, 0x11C4F},
|
||||
@@ -1157,8 +1210,13 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x11D8F, 0x11D8F},
|
||||
{0x11D92, 0x11D92},
|
||||
{0x11D99, 0x11D9F},
|
||||
{0x11DAA, 0x11EDF},
|
||||
{0x11EF9, 0x11FAF},
|
||||
{0x11DAA, 0x11DAF},
|
||||
{0x11DDC, 0x11DDF},
|
||||
{0x11DEA, 0x11EDF},
|
||||
{0x11EF9, 0x11EFF},
|
||||
{0x11F11, 0x11F11},
|
||||
{0x11F3B, 0x11F3D},
|
||||
{0x11F5B, 0x11FAF},
|
||||
{0x11FB1, 0x11FBF},
|
||||
{0x11FF2, 0x11FFE},
|
||||
{0x1239A, 0x123FF},
|
||||
@@ -1166,9 +1224,10 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x12475, 0x1247F},
|
||||
{0x12544, 0x12F8F},
|
||||
{0x12FF3, 0x12FFF},
|
||||
{0x1342F, 0x1342F},
|
||||
{0x13439, 0x143FF},
|
||||
{0x14647, 0x167FF},
|
||||
{0x13456, 0x1345F},
|
||||
{0x143FB, 0x143FF},
|
||||
{0x14647, 0x160FF},
|
||||
{0x1613A, 0x167FF},
|
||||
{0x16A39, 0x16A3F},
|
||||
{0x16A5F, 0x16A5F},
|
||||
{0x16A6A, 0x16A6D},
|
||||
@@ -1180,37 +1239,47 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x16B5A, 0x16B5A},
|
||||
{0x16B62, 0x16B62},
|
||||
{0x16B78, 0x16B7C},
|
||||
{0x16B90, 0x16E3F},
|
||||
{0x16E9B, 0x16EFF},
|
||||
{0x16B90, 0x16D3F},
|
||||
{0x16D7A, 0x16E3F},
|
||||
{0x16E9B, 0x16E9F},
|
||||
{0x16EB9, 0x16EBA},
|
||||
{0x16ED4, 0x16EFF},
|
||||
{0x16F4B, 0x16F4E},
|
||||
{0x16F88, 0x16F8E},
|
||||
{0x16FA0, 0x16FDF},
|
||||
{0x16FE5, 0x16FEF},
|
||||
{0x16FF2, 0x16FFF},
|
||||
{0x17001, 0x187F6},
|
||||
{0x187F8, 0x187FF},
|
||||
{0x18CD6, 0x18CFF},
|
||||
{0x18D01, 0x18D07},
|
||||
{0x18D09, 0x1AFEF},
|
||||
{0x16FF7, 0x16FFF},
|
||||
{0x17001, 0x187FE},
|
||||
{0x18CD6, 0x18CFE},
|
||||
{0x18D01, 0x18D1D},
|
||||
{0x18D1F, 0x18D7F},
|
||||
{0x18DF3, 0x1AFEF},
|
||||
{0x1AFF4, 0x1AFF4},
|
||||
{0x1AFFC, 0x1AFFC},
|
||||
{0x1AFFF, 0x1AFFF},
|
||||
{0x1B123, 0x1B14F},
|
||||
{0x1B153, 0x1B163},
|
||||
{0x1B123, 0x1B131},
|
||||
{0x1B133, 0x1B14F},
|
||||
{0x1B153, 0x1B154},
|
||||
{0x1B156, 0x1B163},
|
||||
{0x1B168, 0x1B16F},
|
||||
{0x1B2FC, 0x1BBFF},
|
||||
{0x1BC6B, 0x1BC6F},
|
||||
{0x1BC7D, 0x1BC7F},
|
||||
{0x1BC89, 0x1BC8F},
|
||||
{0x1BC9A, 0x1BC9B},
|
||||
{0x1BCA4, 0x1CEFF},
|
||||
{0x1BCA4, 0x1CBFF},
|
||||
{0x1CCFD, 0x1CCFF},
|
||||
{0x1CEB4, 0x1CEB9},
|
||||
{0x1CED1, 0x1CEDF},
|
||||
{0x1CEF1, 0x1CEFF},
|
||||
{0x1CF2E, 0x1CF2F},
|
||||
{0x1CF47, 0x1CF4F},
|
||||
{0x1CFC4, 0x1CFFF},
|
||||
{0x1D0F6, 0x1D0FF},
|
||||
{0x1D127, 0x1D128},
|
||||
{0x1D1EB, 0x1D1FF},
|
||||
{0x1D246, 0x1D2DF},
|
||||
{0x1D246, 0x1D2BF},
|
||||
{0x1D2D4, 0x1D2DF},
|
||||
{0x1D2F4, 0x1D2FF},
|
||||
{0x1D357, 0x1D35F},
|
||||
{0x1D379, 0x1D3FF},
|
||||
@@ -1237,19 +1306,28 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x1DA8C, 0x1DA9A},
|
||||
{0x1DAA0, 0x1DAA0},
|
||||
{0x1DAB0, 0x1DEFF},
|
||||
{0x1DF1F, 0x1DFFF},
|
||||
{0x1DF1F, 0x1DF24},
|
||||
{0x1DF2B, 0x1DFFF},
|
||||
{0x1E007, 0x1E007},
|
||||
{0x1E019, 0x1E01A},
|
||||
{0x1E022, 0x1E022},
|
||||
{0x1E025, 0x1E025},
|
||||
{0x1E02B, 0x1E0FF},
|
||||
{0x1E02B, 0x1E02F},
|
||||
{0x1E06E, 0x1E08E},
|
||||
{0x1E090, 0x1E0FF},
|
||||
{0x1E12D, 0x1E12F},
|
||||
{0x1E13E, 0x1E13F},
|
||||
{0x1E14A, 0x1E14D},
|
||||
{0x1E150, 0x1E28F},
|
||||
{0x1E2AF, 0x1E2BF},
|
||||
{0x1E2FA, 0x1E2FE},
|
||||
{0x1E300, 0x1E7DF},
|
||||
{0x1E300, 0x1E4CF},
|
||||
{0x1E4FA, 0x1E5CF},
|
||||
{0x1E5FB, 0x1E5FE},
|
||||
{0x1E600, 0x1E6BF},
|
||||
{0x1E6DF, 0x1E6DF},
|
||||
{0x1E6F6, 0x1E6FD},
|
||||
{0x1E700, 0x1E7DF},
|
||||
{0x1E7E7, 0x1E7E7},
|
||||
{0x1E7EC, 0x1E7EC},
|
||||
{0x1E7EF, 0x1E7EF},
|
||||
@@ -1307,11 +1385,10 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x1F249, 0x1F24F},
|
||||
{0x1F252, 0x1F25F},
|
||||
{0x1F266, 0x1F2FF},
|
||||
{0x1F6D8, 0x1F6DC},
|
||||
{0x1F6D9, 0x1F6DB},
|
||||
{0x1F6ED, 0x1F6EF},
|
||||
{0x1F6FD, 0x1F6FF},
|
||||
{0x1F774, 0x1F77F},
|
||||
{0x1F7D9, 0x1F7DF},
|
||||
{0x1F7DA, 0x1F7DF},
|
||||
{0x1F7EC, 0x1F7EF},
|
||||
{0x1F7F1, 0x1F7FF},
|
||||
{0x1F80C, 0x1F80F},
|
||||
@@ -1319,34 +1396,37 @@ static const struct widechar_range widechar_unassigned_table[] = {
|
||||
{0x1F85A, 0x1F85F},
|
||||
{0x1F888, 0x1F88F},
|
||||
{0x1F8AE, 0x1F8AF},
|
||||
{0x1F8B2, 0x1F8FF},
|
||||
{0x1FA54, 0x1FA5F},
|
||||
{0x1F8BC, 0x1F8BF},
|
||||
{0x1F8C2, 0x1F8CF},
|
||||
{0x1F8D9, 0x1F8FF},
|
||||
{0x1FA58, 0x1FA5F},
|
||||
{0x1FA6E, 0x1FA6F},
|
||||
{0x1FA75, 0x1FA77},
|
||||
{0x1FA7D, 0x1FA7F},
|
||||
{0x1FA87, 0x1FA8F},
|
||||
{0x1FAAD, 0x1FAAF},
|
||||
{0x1FABB, 0x1FABF},
|
||||
{0x1FAC6, 0x1FACF},
|
||||
{0x1FADA, 0x1FADF},
|
||||
{0x1FAE8, 0x1FAEF},
|
||||
{0x1FAF7, 0x1FAFF},
|
||||
{0x1FA8B, 0x1FA8D},
|
||||
{0x1FAC7, 0x1FAC7},
|
||||
{0x1FAC9, 0x1FACC},
|
||||
{0x1FADD, 0x1FADE},
|
||||
{0x1FAEB, 0x1FAEE},
|
||||
{0x1FAF9, 0x1FAFF},
|
||||
{0x1FB93, 0x1FB93},
|
||||
{0x1FBCB, 0x1FBEF},
|
||||
{0x1FBFA, 0x1FFFD},
|
||||
{0x1FBFB, 0x1FFFD},
|
||||
{0x20001, 0x2A6DE},
|
||||
{0x2A6E0, 0x2A6FF},
|
||||
{0x2A701, 0x2B737},
|
||||
{0x2B739, 0x2B73F},
|
||||
{0x2A701, 0x2B73E},
|
||||
{0x2B741, 0x2B81C},
|
||||
{0x2B81E, 0x2B81F},
|
||||
{0x2B821, 0x2CEA0},
|
||||
{0x2CEA2, 0x2CEAF},
|
||||
{0x2B821, 0x2CEAC},
|
||||
{0x2CEAE, 0x2CEAF},
|
||||
{0x2CEB1, 0x2EBDF},
|
||||
{0x2EBE1, 0x2F7FF},
|
||||
{0x2EBE1, 0x2EBEF},
|
||||
{0x2EBF1, 0x2EE5C},
|
||||
{0x2EE5E, 0x2F7FF},
|
||||
{0x2FA1E, 0x2FFFD},
|
||||
{0x30001, 0x31349},
|
||||
{0x3134B, 0x3FFFD},
|
||||
{0x3134B, 0x3134F},
|
||||
{0x31351, 0x323AE},
|
||||
{0x323B1, 0x33478},
|
||||
{0x3347A, 0x3FFFD},
|
||||
{0x40000, 0x4FFFD},
|
||||
{0x50000, 0x5FFFD},
|
||||
{0x60000, 0x6FFFD},
|
||||
@@ -1463,7 +1543,7 @@ bool widechar_in_table(const Collection &arr, uint32_t c) {
|
||||
}
|
||||
|
||||
/* Return the width of character c, or a special negative value. */
|
||||
int wcwidth(uint32_t c) {
|
||||
int widechar_wcwidth(uint32_t c) {
|
||||
if (widechar_in_table(widechar_ascii_table, c))
|
||||
return 1;
|
||||
if (widechar_in_table(widechar_private_table, c))
|
||||
@@ -1488,4 +1568,4 @@ int wcwidth(uint32_t c) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
#endif // WIDECHAR_WIDTH_H
|
||||
#endif // WIDECHAR_WIDTH_H
|
||||
@@ -17,7 +17,6 @@ tab-size = 4
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <codecvt>
|
||||
#include <ctime>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@@ -26,6 +25,7 @@ tab-size = 4
|
||||
#include <sstream>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
@@ -211,28 +211,53 @@ namespace Term {
|
||||
|
||||
namespace Tools {
|
||||
|
||||
size_t wide_ulen(const std::string_view str) {
|
||||
unsigned int chars = 0;
|
||||
try {
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
|
||||
auto w_str = conv.from_bytes((str.size() > 10000 ? str.substr(0, 10000).data() : str.data()));
|
||||
|
||||
for (auto c : w_str) {
|
||||
chars += utf8::wcwidth(c);
|
||||
}
|
||||
string replace_ascii_control(string str, const char replacement) {
|
||||
if (str.empty())
|
||||
return str;
|
||||
const char* str_data = &str.data()[0];
|
||||
size_t w_len = 1 + std::mbstowcs(nullptr, str_data, 0);
|
||||
if (w_len <= 1) {
|
||||
std::ranges::for_each(str, [&replacement](char& c) { if (c < 0x20) c = replacement; });
|
||||
return str;
|
||||
}
|
||||
catch (...) {
|
||||
vector<wchar_t> w_str(w_len);
|
||||
std::mbstowcs(&w_str[0], str_data, w_len);
|
||||
for (size_t i = 0; i < w_str.size(); i++) {
|
||||
if (widechar_wcwidth(w_str[i]) > 1)
|
||||
continue;
|
||||
if (w_str[i] < 0x20)
|
||||
w_str[i] = replacement;
|
||||
}
|
||||
str.resize(w_str.size());
|
||||
std::wcstombs(&str[0], &w_str[0], w_str.size());
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
size_t wide_ulen(const std::string_view str) {
|
||||
if (str.empty())
|
||||
return 0;
|
||||
unsigned int chars = 0;
|
||||
|
||||
const char* str_data = &str.data()[0];
|
||||
size_t w_len = 1 + std::mbstowcs(nullptr, str_data, 0);
|
||||
if (w_len <= 1)
|
||||
return ulen(str);
|
||||
vector<wchar_t> w_str(w_len);
|
||||
std::mbstowcs(&w_str[0], str_data, w_len);
|
||||
|
||||
for (auto c : w_str) {
|
||||
chars += widechar_wcwidth(c);
|
||||
}
|
||||
|
||||
return chars;
|
||||
}
|
||||
|
||||
size_t wide_ulen(const std::wstring_view w_str) {
|
||||
size_t wide_ulen(const vector<wchar_t> w_str) {
|
||||
unsigned int chars = 0;
|
||||
|
||||
for (auto c : w_str) {
|
||||
chars += utf8::wcwidth(c);
|
||||
chars += widechar_wcwidth(c);
|
||||
}
|
||||
|
||||
return chars;
|
||||
@@ -243,17 +268,20 @@ namespace Tools {
|
||||
return "";
|
||||
|
||||
if (wide) {
|
||||
try {
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
|
||||
auto w_str = conv.from_bytes((str.size() > 10000 ? str.substr(0, 10000).c_str() : str.c_str()));
|
||||
while (wide_ulen(w_str) > len)
|
||||
w_str.pop_back();
|
||||
string n_str = conv.to_bytes(w_str);
|
||||
return n_str;
|
||||
}
|
||||
catch (...) {
|
||||
const char* str_data = &str.data()[0];
|
||||
size_t w_len = 1 + std::mbstowcs(nullptr, str_data, 0);
|
||||
if (w_len <= 1)
|
||||
return uresize(str, len, false);
|
||||
}
|
||||
vector<wchar_t> w_str(w_len);
|
||||
std::mbstowcs(&w_str[0], str_data, w_len);
|
||||
|
||||
while (wide_ulen(w_str) > len) w_str.pop_back();
|
||||
|
||||
string n_str;
|
||||
n_str.resize(w_str.size());
|
||||
std::wcstombs(&n_str[0], &w_str[0], w_str.size());
|
||||
|
||||
return n_str;
|
||||
}
|
||||
else {
|
||||
for (size_t x = 0, i = 0; i < str.size(); i++) {
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace Tools {
|
||||
};
|
||||
|
||||
size_t wide_ulen(const std::string_view str);
|
||||
size_t wide_ulen(const std::wstring_view w_str);
|
||||
size_t wide_ulen(const vector<wchar_t> w_str);
|
||||
|
||||
//* Return number of UTF8 characters in a string (wide=true for column size needed on terminal)
|
||||
inline size_t ulen(const std::string_view str, bool wide = false) {
|
||||
@@ -186,10 +186,7 @@ namespace Tools {
|
||||
string s_replace(const string& str, const string& from, const string& to);
|
||||
|
||||
//* Replace ascii control characters with <replacement> in <str> and return new string
|
||||
inline string replace_ascii_control(string str, const char replacement = ' ') {
|
||||
std::ranges::for_each(str, [&replacement](char& c) { if (c < 0x20) c = replacement; });
|
||||
return str;
|
||||
}
|
||||
string replace_ascii_control(string str, const char replacement = ' ');
|
||||
|
||||
//* Capitalize <str>
|
||||
inline string capitalize(string str) {
|
||||
|
||||
Reference in New Issue
Block a user