]> granicus.if.org Git - php/commitdiff
0x7E is not a tilde in Shift-JIS{,-2004}
authorAlex Dowad <alexinbeijing@gmail.com>
Sat, 14 Nov 2020 19:51:23 +0000 (21:51 +0200)
committerAlex Dowad <alexinbeijing@gmail.com>
Wed, 25 Nov 2020 18:51:45 +0000 (20:51 +0200)
ext/mbstring/libmbfl/filters/mbfilter_sjis.c
ext/mbstring/libmbfl/filters/unicode_table_jis2004.h
ext/mbstring/tests/sjis2004_encoding.phpt
ext/mbstring/tests/sjis_encoding.phpt

index 39e7879c1a065667ccf709806f416dbf8ff410a6..36f374a952625cc3dcb5d8d3c8c9f93bcb65e629 100644 (file)
@@ -207,6 +207,10 @@ int mbfl_filt_conv_wchar_sjis(int c, mbfl_convert_filter *filter)
                /* Unicode 0x5C is a backslash; but Shift-JIS uses 0x5C for the
                 * Yen sign. JIS X 0208 kuten 0x2140 is a backslash. */
                s1 = 0x2140;
+       } else if (c == 0x7E) {
+               /* Unicode 0x7E is a tilde, but Shift-JIS uses 0x7E for overline (or
+                * macron). JIS X 0208 kuten 0x2141 is 'WAVE DASH' */
+               s1 = 0x2141;
        } else if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) {
                s1 = ucs_a1_jis_table[c - ucs_a1_jis_table_min];
        } else if (c >= ucs_a2_jis_table_min && c < ucs_a2_jis_table_max) {
index c8bc433d349ca44c3f8d2bf1d5ac463d19fdcd20..09f7c4372617840a582440c60ee5f899630ab894 100644 (file)
@@ -1612,7 +1612,7 @@ static const unsigned short ucs_a1_jisx0213_table[] = { // 0x0000 - 0x045f
 0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067,
 0x0068,0x0069,0x006A,0x006B,0x006C,0x006D,0x006E,0x006F,
 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
-0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
+0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x2141,0x007F,
 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
index 3278e85dfe5f8604abdf34fc9cd5f5d8a133b15a..3b4299e753bf6b74cc95e5a344e762fb227355d0 100644 (file)
@@ -36,7 +36,9 @@ while ($line = fgets($fp, 256)) {
                }
        }
 }
-$fromUnicode["\x00\x7E"] = "\x7E"; /* Not reversible; SJIS 0x7E -> U+203E */
+
+/* U+007E is TILDE, Shift-JIS 0x8160 is WAVE DASH */
+$fromUnicode["\x00\x7E"] = "\x81\x60";
 
 /* U+005C is backslash, Shift-JIS 0x815F is REVERSE SOLIDUS
  * (ie. a fancy way to say "backslash") */
index a75ce85a4f81f97e04a1dd5c3fb5fb5977862773..8ac3b0563ed4f9b0e399e1c31902d8aa48e24476 100644 (file)
@@ -19,12 +19,11 @@ for ($i = 0; $i < 0x20; $i++) {
   $fromUnicode["\x00" . chr($i)] = chr($i);
 }
 
+/* U+007E is TILDE; convert to Shift-JIS 0x8160 (WAVE DASH) */
+$fromUnicode["\x00\x7E"] = "\x81\x60";
 /* DEL character */
 $validChars["\x7F"] = "\x00\x7F";
 $fromUnicode["\x00\x7F"] = "\x7F";
-/* Although Shift-JIS uses 0x7E for an overline, we will map Unicode 0x7E
- * (tilde) to Shift-JIS 0x7E (as iconv does) */
-$fromUnicode["\x00\x7E"] = "\x7E";
 /* Use fullwidth reverse solidus, not (halfwidth) backslash (0x5C) */
 $validChars["\x81\x5F"] = "\xFF\x3C";
 $fromUnicode["\xFF\x3C"] = "\x81\x5F";