summaryrefslogtreecommitdiffstats
path: root/src/libvterm/find-wide-chars.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 08:50:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 08:50:31 +0000
commitaed8ce9da277f5ecffe968b324f242c41c3b752a (patch)
treed2e538394cb7a8a7c42a4aac6ccf1a8e3256999b /src/libvterm/find-wide-chars.pl
parentInitial commit. (diff)
downloadvim-aed8ce9da277f5ecffe968b324f242c41c3b752a.tar.xz
vim-aed8ce9da277f5ecffe968b324f242c41c3b752a.zip
Adding upstream version 2:9.0.1378.upstream/2%9.0.1378upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libvterm/find-wide-chars.pl')
-rw-r--r--src/libvterm/find-wide-chars.pl30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/libvterm/find-wide-chars.pl b/src/libvterm/find-wide-chars.pl
new file mode 100644
index 0000000..f7f2205
--- /dev/null
+++ b/src/libvterm/find-wide-chars.pl
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+STDOUT->autoflush(1);
+
+sub iswide
+{
+ my ( $cp ) = @_;
+ return chr($cp) =~ m/\p{East_Asian_Width=Wide}|\p{East_Asian_Width=Fullwidth}/;
+}
+
+my ( $start, $end );
+foreach my $cp ( 0 .. 0x1FFFF ) {
+ iswide($cp) or next;
+
+ if( defined $end and $end == $cp-1 ) {
+ # extend the range
+ $end = $cp;
+ next;
+ }
+
+ # start a new range
+ printf " { %#04x, %#04x },\n", $start, $end if defined $start;
+
+ $start = $end = $cp;
+}
+
+printf " { %#04x, %#04x },\n", $start, $end if defined $start;