Skip to content

Commit 13479ee

Browse files
committed
Restore backwards-compatible mappings for 0x5C/0x7E in SJIS (for fast conversion filter)
In d62f535, the legacy mbstring conversion filters for Shift-JIS was updated to restore backwards-compatible mappings for 0x5C/0x7E. Make the same change to the newer fast conversion filters.
1 parent 85a95a2 commit 13479ee

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug GH-8655 (Casting an object to array does not unwrap refcount=1
77
references). (Nicolas Grekas)
88

9+
- MBString:
10+
. Backwards-compatible mappings for 0x5C/0x7E in Shift-JIS are restored,
11+
after they had been changed in 8.1.0. (Alex Dowad)
12+
913
09 Jun 2022, PHP 8.2.0alpha1
1014

1115
- CLI:

ext/mbstring/libmbfl/filters/mbfilter_sjis.c

+5-17
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,7 @@ static size_t mb_sjis_to_wchar(unsigned char **in, size_t *in_len, uint32_t *buf
257257
while (p < e && out < limit) {
258258
unsigned char c = *p++;
259259

260-
if (c == 0x5C) {
261-
*out++ = 0xA5;
262-
} else if (c == 0x7E) {
263-
*out++ = 0x203E;
264-
} else if (c <= 0x7F) {
260+
if (c <= 0x7F) {
265261
*out++ = c;
266262
} else if (c >= 0xA1 && c <= 0xDF) { /* Kana */
267263
*out++ = 0xFEC0 + c;
@@ -302,17 +298,7 @@ static void mb_wchar_to_sjis(uint32_t *in, size_t len, mb_convert_buf *buf, bool
302298
uint32_t w = *in++;
303299
unsigned int s = 0;
304300

305-
if (w == 0x5C) {
306-
/* Unicode 0x5C is a backslash; but Shift-JIS uses 0x5C for the
307-
* Yen sign. JIS X 0208 kuten 0x2140 is a backslash. */
308-
s = 0x2140;
309-
} else if (w == 0x7E) {
310-
/* Unicode 0x7E is a tilde, but Shift-JIS uses 0x7E for overline (or
311-
* macron). JIS X 0208 kuten 0x2141 is 'WAVE DASH' */
312-
s = 0x2141;
313-
} else if (w == 0xAF || w == 0x203E) { /* U+00AF is MACRON, U+203E is OVERLINE */
314-
s = 0x7E; /* Halfwidth overline/macron */
315-
} else if (w >= ucs_a1_jis_table_min && w < ucs_a1_jis_table_max) {
301+
if (w >= ucs_a1_jis_table_min && w < ucs_a1_jis_table_max) {
316302
s = ucs_a1_jis_table[w - ucs_a1_jis_table_min];
317303
} else if (w >= ucs_a2_jis_table_min && w < ucs_a2_jis_table_max) {
318304
s = ucs_a2_jis_table[w - ucs_a2_jis_table_min];
@@ -324,7 +310,9 @@ static void mb_wchar_to_sjis(uint32_t *in, size_t len, mb_convert_buf *buf, bool
324310

325311
if (s == 0) {
326312
if (w == 0xA5) { /* YEN SIGN */
327-
s = 0x5C;
313+
s = 0x216F; /* FULLWIDTH YEN SIGN */
314+
} else if (w == 0xAF || w == 0x203E) {
315+
s = 0x2131; /* FULLWIDTH MACRON */
328316
} else if (w == 0xFF3C) { /* FULLWIDTH REVERSE SOLIDUS */
329317
s = 0x2140;
330318
} else if (w == 0x2225) { /* PARALLEL TO */

0 commit comments

Comments
 (0)