]> Savannah Git Hosting - gnulib.git/commitdiff
uniwidth: Give width 0 to conjoining Hangul Jamo jungseong, jongseong.
authorBruno Haible <bruno@clisp.org>
Thu, 30 Dec 2021 00:09:20 +0000 (01:09 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 30 Dec 2021 00:09:20 +0000 (01:09 +0100)
Reported by Luis Javier Merino <ninjalj@gmail.com> in
<https://lists.gnu.org/archive/html/bug-libunistring/2021-12/msg00006.html>.

* lib/gen-uni-tables.c (is_nonspacing): Return true for the conjoining
Hangul Jamo jungseong and jongseong characters.
* lib/uniwidth/width.c (nonspacing_table_data, nonspacing_table_ind):
Regenerated.
* tests/uniwidth/test-uc_width2.sh: Expect width 0 for the characters
0x1160..0x11FF, 0xD7B0..0xD7C6, 0xD7CB..0xD7FB.

ChangeLog
lib/gen-uni-tables.c
lib/uniwidth/width.c
tests/uniwidth/test-uc_width2.sh

index 874e89b004b57ef7811b28a44d99683280841cc0..eeaeabc577e0612babcf37bc161d1f8b0fa882f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2021-12-29  Bruno Haible  <bruno@clisp.org>
+
+       uniwidth: Give width 0 to conjoining Hangul Jamo jungseong, jongseong.
+       Reported by Luis Javier Merino <ninjalj@gmail.com> in
+       <https://lists.gnu.org/archive/html/bug-libunistring/2021-12/msg00006.html>.
+       * lib/gen-uni-tables.c (is_nonspacing): Return true for the conjoining
+       Hangul Jamo jungseong and jongseong characters.
+       * lib/uniwidth/width.c (nonspacing_table_data, nonspacing_table_ind):
+       Regenerated.
+       * tests/uniwidth/test-uc_width2.sh: Expect width 0 for the characters
+       0x1160..0x11FF, 0xD7B0..0xD7C6, 0xD7CB..0xD7FB.
+
 2021-12-29  Bruno Haible  <bruno@clisp.org>
 
        uniwidth: Update to Unicode 10.0.0.
index a5464b225ebf5534fe66f5ddf89afb822a8a4b54..85ad5c439e121c6c5ba7b831729c935502f17a95 100644 (file)
@@ -6289,12 +6289,27 @@ fill_width (const char *width_filename)
 /* Non-spacing attribute and width.  */
 
 /* The non-spacing attribute table consists of:
-   - Non-spacing characters; generated from PropList.txt or
+   * Non-spacing characters; generated from PropList.txt or
      "grep '^[^;]*;[^;]*;[^;]*;[^;]*;NSM;' UnicodeData.txt"
-   - Format control characters; generated from
+   * Format control characters; generated from
      "grep '^[^;]*;[^;]*;Cf;' UnicodeData.txt"
-   - Zero width characters; generated from
+   * Zero width characters; generated from
      "grep '^[^;]*;ZERO WIDTH ' UnicodeData.txt"
+   * Hangul Jamo characters that have conjoining behaviour:
+       - jungseong = syllable-middle vowels
+       - jongseong = syllable-final consonants
+     Rationale:
+     1) These characters act like combining characters. They have no
+     equivalent in legacy character sets. Therefore the EastAsianWidth.txt
+     file does not really matter for them; UAX #11 East Asian Width
+     <https://www.unicode.org/reports/tr11/> makes it clear that it focus
+     is on compatibility with traditional Japanese layout.
+     By contrast, the same glyphs without conjoining behaviour are available
+     in the U+3130..U+318F block, and these characters are mapped to legacy
+     character sets, and traditional Japanese layout matters for them.
+     2) glibc does the same thing, see
+     <https://sourceware.org/bugzilla/show_bug.cgi?id=21750>
+     <https://sourceware.org/bugzilla/show_bug.cgi?id=26120>
  */
 
 static bool
@@ -6303,7 +6318,10 @@ is_nonspacing (unsigned int ch)
   return (unicode_attributes[ch].name != NULL
           && (get_bidi_category (ch) == UC_BIDI_NSM
               || is_category_Cc (ch) || is_category_Cf (ch)
-              || strncmp (unicode_attributes[ch].name, "ZERO WIDTH ", 11) == 0));
+              || strncmp (unicode_attributes[ch].name, "ZERO WIDTH ", 11) == 0
+              || (ch >= 0x1160 && ch <= 0x11A7) || (ch >= 0xD7B0 && ch <= 0xD7C6) /* jungseong */
+              || (ch >= 0x11A8 && ch <= 0x11FF) || (ch >= 0xD7CB && ch <= 0xD7FB) /* jongseong */
+         )   );
 }
 
 static void
index 4db700ea1a5ef0f3101c23addc5e29a48383f43e..0cee3fb365efad01a4181449acd3a75f6eb5f8c7 100644 (file)
 
 #include "cjk.h"
 
-/*
- * Non-spacing attribute table.
- * Consists of:
- * - Non-spacing characters; generated from PropList.txt or
- *   "grep '^[^;]*;[^;]*;[^;]*;[^;]*;NSM;' UnicodeData.txt"
- * - Format control characters; generated from
- *   "grep '^[^;]*;[^;]*;Cf;' UnicodeData.txt"
- * - Zero width characters; generated from
- *   "grep '^[^;]*;ZERO WIDTH ' UnicodeData.txt"
+/* The non-spacing attribute table consists of:
+   * Non-spacing characters; generated from PropList.txt or
+     "grep '^[^;]*;[^;]*;[^;]*;[^;]*;NSM;' UnicodeData.txt"
+   * Format control characters; generated from
+     "grep '^[^;]*;[^;]*;Cf;' UnicodeData.txt"
+   * Zero width characters; generated from
+     "grep '^[^;]*;ZERO WIDTH ' UnicodeData.txt"
+   * Hangul Jamo characters that have conjoining behaviour:
+       - jungseong = syllable-middle vowels
+       - jongseong = syllable-final consonants
+     Rationale:
+     1) These characters act like combining characters. They have no
+     equivalent in legacy character sets. Therefore the EastAsianWidth.txt
+     file does not really matter for them; UAX #11 East Asian Width
+     <https://www.unicode.org/reports/tr11/> makes it clear that it focus
+     is on compatibility with traditional Japanese layout.
+     By contrast, the same glyphs without conjoining behaviour are available
+     in the U+3130..U+318F block, and these characters are mapped to legacy
+     character sets, and traditional Japanese layout matters for them.
+     2) glibc does the same thing, see
+     <https://sourceware.org/bugzilla/show_bug.cgi?id=21750>
+     <https://sourceware.org/bugzilla/show_bug.cgi?id=26120>
  */
-static const unsigned char nonspacing_table_data[39*64] = {
+static const unsigned char nonspacing_table_data[40*64] = {
   /* 0x0000-0x01ff */
   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0x0000-0x003f */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x0040-0x007f */
@@ -111,9 +124,9 @@ static const unsigned char nonspacing_table_data[39*64] = {
   0x64, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x1080-0x10bf */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c0-0x10ff */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1100-0x113f */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1140-0x117f */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1180-0x11bf */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11c0-0x11ff */
+  0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, /* 0x1140-0x117f */
+  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x1180-0x11bf */
+  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x11c0-0x11ff */
   /* 0x1200-0x13ff */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1200-0x123f */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1240-0x127f */
@@ -213,6 +226,15 @@ static const unsigned char nonspacing_table_data[39*64] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab40-0xab7f */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab80-0xabbf */
   0x00, 0x00, 0x00, 0x00, 0x20, 0x21, 0x00, 0x00, /* 0xabc0-0xabff */
+  /* 0xd600-0xd7ff */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd600-0xd63f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd640-0xd67f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd680-0xd6bf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd6c0-0xd6ff */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd700-0xd73f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd740-0xd77f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0xd780-0xd7bf */
+  0x7f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, /* 0xd7c0-0xd7ff */
   /* 0xfa00-0xfbff */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa00-0xfa3f */
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa40-0xfa7f */
@@ -399,24 +421,24 @@ static const signed char nonspacing_table_ind[248] = {
   -1, -1, -1, 17, 18, 19, -1, -1, /* 0xa000-0xafff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb000-0xbfff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc000-0xcfff */
-  -1, -1, -1, -1, -1, -1, -1, -1, /* 0xd000-0xdfff */
+  -1, -1, -1, 20, -1, -1, -1, -1, /* 0xd000-0xdfff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe000-0xefff */
-  -1, -1, -1, -1, -1, 20, -1, 21, /* 0xf000-0xffff */
-  22, 23, -1, -1, -1, 24, -1, -1, /* 0x10000-0x10fff */
-  25, 26, 27, 28, -1, 29, 30, -1, /* 0x11000-0x11fff */
+  -1, -1, -1, -1, -1, 21, -1, 22, /* 0xf000-0xffff */
+  23, 24, -1, -1, -1, 25, -1, -1, /* 0x10000-0x10fff */
+  26, 27, 28, 29, -1, 30, 31, -1, /* 0x11000-0x11fff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0x12000-0x12fff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0x13000-0x13fff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0x14000-0x14fff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0x15000-0x15fff */
-  -1, -1, -1, -1, -1, 31, -1, 32, /* 0x16000-0x16fff */
+  -1, -1, -1, -1, -1, 32, -1, 33, /* 0x16000-0x16fff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0x17000-0x17fff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0x18000-0x18fff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0x19000-0x19fff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1a000-0x1afff */
-  -1, -1, -1, -1, -1, -1, 33, -1, /* 0x1b000-0x1bfff */
+  -1, -1, -1, -1, -1, -1, 34, -1, /* 0x1b000-0x1bfff */
   -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1c000-0x1cfff */
-  34, 35, -1, -1, -1, 36, -1, -1, /* 0x1d000-0x1dfff */
-  37, -1, -1, -1, 38, -1, -1, -1  /* 0x1e000-0x1efff */
+  35, 36, -1, -1, -1, 37, -1, -1, /* 0x1d000-0x1dfff */
+  38, -1, -1, -1, 39, -1, -1, -1  /* 0x1e000-0x1efff */
 };
 
 /* Determine number of column positions required for UC.  */
index 9662ca71f5872fb154c486c1480fbb19b1838fbe..6f462797bb8c09288620e783414dd5e371b22fc1 100755 (executable)
@@ -233,7 +233,8 @@ cat > uc_width.ok <<\EOF
 109D           0
 109E..10FF     A
 1100..115F     2
-1160..135C     A
+1160..11FF     0
+1200..135C     A
 135D..135F     0
 1360..1711     A
 1712..1714     0
@@ -503,7 +504,11 @@ ABE9..ABEC A
 ABED           0
 ABEE..ABFF     A
 AC00..D7A3     2
-D7A4..F8FF     A
+D7A4..D7AF     A
+D7B0..D7C6     0
+D7C7..D7CA     A
+D7CB..D7FB     0
+D7FC..F8FF     A
 F900..FAFF     2
 FB00..FB1D     A
 FB1E           0