mirror of
https://github.com/php/php-src.git
synced 2024-11-24 18:34:21 +08:00
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Restore backwards-compatible mappings of U+005C and U+007E to SJIS-2004
This commit is contained in:
commit
9beb93f2cf
@ -24,9 +24,15 @@
|
||||
/*
|
||||
* The source code included in this files was separated from mbfilter_sjis.c
|
||||
* by rui hirokawa <hirokawa@php.net> on 15 aug 2011.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Although the specification for Shift-JIS-2004 indicates that 0x5C and
|
||||
* 0x7E should (respectively) represent a Yen sign and an overbar, feedback
|
||||
* from Japanese PHP users indicates that they prefer 0x5C and 0x7E to be
|
||||
* treated as equivalent to U+005C and U+007E. This is the historical
|
||||
* behavior of mbstring, and promotes compatibility with other software
|
||||
* which handles Shift-JIS and Shift-JIS-2004 text in this way. */
|
||||
|
||||
#include "mbfilter.h"
|
||||
#include "mbfilter_sjis_2004.h"
|
||||
#include "mbfilter_euc_jp_2004.h"
|
||||
@ -565,13 +571,6 @@ retry:
|
||||
}
|
||||
}
|
||||
|
||||
if (s1 <= 0 && (filter->to->no_encoding == mbfl_no_encoding_2022jp_2004 || filter->to->no_encoding == mbfl_no_encoding_eucjp2004) && (c == 0x5C || c == 0x7E)) {
|
||||
/* ISO-2022-JP-2004 can represent ASCII characters directly, so there is no need
|
||||
* to use the JIS X 0208 REVERSE SOLIDUS for ASCII backslash, or WAVE DASH for tilde
|
||||
* Likewise for EUC-JP-2004 */
|
||||
s1 = c;
|
||||
}
|
||||
|
||||
/* check for major japanese chars: U+4E00 - U+9FFF */
|
||||
if (s1 <= 0) {
|
||||
for (k = 0; k < uni2jis_tbl_len; k++) {
|
||||
@ -1077,12 +1076,6 @@ process_codepoint: ;
|
||||
}
|
||||
}
|
||||
|
||||
if (!s && (w == 0x5C || w == 0x7E)) {
|
||||
/* EUC-JP-2004 can represent ASCII characters directly, so there is no need
|
||||
* to use the JIS X 0208 REVERSE SOLIDUS for ASCII backslash, or WAVE DASH for tilde */
|
||||
s = w;
|
||||
}
|
||||
|
||||
/* Check for major Japanese chars: U+4E00-U+9FFF */
|
||||
if (!s) {
|
||||
for (int k = 0; k < uni2jis_tbl_len; k++) {
|
||||
@ -1336,12 +1329,6 @@ process_codepoint: ;
|
||||
}
|
||||
}
|
||||
|
||||
if (!s && (w == 0x5C || w == 0x7E)) {
|
||||
/* ISO-2022-JP-2004 can represent ASCII characters directly, so there is no need
|
||||
* to use the JIS X 0208 REVERSE SOLIDUS for ASCII backslash, or WAVE DASH for tilde */
|
||||
s = w;
|
||||
}
|
||||
|
||||
/* Check for major Japanese chars: U+4E00-U+9FFF */
|
||||
if (!s) {
|
||||
for (int k = 0; k < uni2jis_tbl_len; k++) {
|
||||
|
@ -1608,11 +1608,11 @@ static const unsigned short ucs_a1_jisx0213_table[] = { // 0x0000 - 0x045f
|
||||
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,
|
||||
0x0048,0x0049,0x004A,0x004B,0x004C,0x004D,0x004E,0x004F,
|
||||
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057,
|
||||
0x0058,0x0059,0x005A,0x005B,0x2140,0x005D,0x005E,0x005F,
|
||||
0x0058,0x0059,0x005A,0x005B,0x005C,0x005D,0x005E,0x005F,
|
||||
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,0x2141,0x007F,
|
||||
0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,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,
|
||||
|
@ -38,12 +38,8 @@ while ($line = fgets($fp, 256)) {
|
||||
}
|
||||
}
|
||||
|
||||
/* 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") */
|
||||
$fromUnicode["\x00\x5C"] = "\x81\x5F";
|
||||
$fromUnicode["\x00\x7E"] = "\x7E";
|
||||
$fromUnicode["\x00\x5C"] = "\x5C";
|
||||
|
||||
testAllValidChars($validChars, 'SJIS-2004', 'UTF-32BE');
|
||||
echo "SJIS-2004 verification and conversion works for all valid characters\n";
|
||||
|
Loading…
Reference in New Issue
Block a user