aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2024-11-13 22:12:42 +0000
committerKyle Evans <kevans@FreeBSD.org>2024-11-13 22:12:42 +0000
commit160c36eae41afa3c4944ed44778c2b48db8fbb77 (patch)
tree50de8b77a1ceebf167a797a9afab4744d54df013 /tools
parenta4b7367eb027a99b9eb48bf18951049434a9e189 (diff)
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/locale/tools/getwidths.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/tools/locale/tools/getwidths.c b/tools/tools/locale/tools/getwidths.c
index 2790b8031912..63c62791253f 100644
--- a/tools/tools/locale/tools/getwidths.c
+++ b/tools/tools/locale/tools/getwidths.c
@@ -28,6 +28,21 @@
#include <utf8proc.h>
+static int
+width_of(int32_t wc)
+{
+
+ /*
+ * Hangul Jamo medial vowels and final consonants are more of
+ * a combining character, and should be considered zero-width.
+ */
+ if (wc >= 0x1160 && wc <= 0x11ff)
+ return (0);
+
+ /* No override by default, trust utf8proc's width. */
+ return (utf8proc_charwidth(wc));
+}
+
int
main(void)
{
@@ -43,9 +58,10 @@ main(void)
wcc = utf8proc_category(wc);
if (wcc == UTF8PROC_CATEGORY_CC)
continue;
- wcw = utf8proc_charwidth(wc);
+ wcw = width_of(wc);
if (wcw == 1)
continue;
+
printf("%04X %d\n", wc, wcw);
}