mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix legacy text conversion filter for SJIS-2004
EUC-JP-2004 includes special byte sequences starting with 0x8E for kana. The legacy output routine for EUC-JP-2004 emits these sequences if the value of the output variable `s` is between 0x80 and 0xFF. Since the same routine was also used for SJIS-2004 and ISO-2022-JP-2004, before8a915ed26c
, the same 0x8E sequences would be emitted when converting to those text encodings as well. But that is completely wrong. 0x8E 0x__ does not mean the same in SJIS-2004 or ISO-2022-JP-2004 as it does in EUC-JP-2004. Therefore, in8a915ed26c
, I fixed the legacy conversion routine by checking whether the output encoding is EUC-JP-2004 or not. If it's not, and `s` is 0x80-0xFF, I made it emit an error. Well, it turns out that single bytes with values from 0xA1 to 0xDF are meaningful in SJIS-2004. To emit these bytes when appropriate, I had to amend the legacy conversion routine again. (For clarity, this does NOT mean reverting to the behavior prior to8a915ed26c
. We were right not to emit sequences starting with 0x8E in SJIS-2004. But in SJIS-2004, we *do* sometimes need to emit single bytes from 0xA1-0xDF.)
This commit is contained in:
parent
3517a70f93
commit
18e526cb51
1 changed files with 2 additions and 0 deletions
|
@ -633,6 +633,8 @@ retry:
|
||||||
if (filter->to->no_encoding == mbfl_no_encoding_eucjp2004) {
|
if (filter->to->no_encoding == mbfl_no_encoding_eucjp2004) {
|
||||||
CK((*filter->output_function)(0x8e, filter->data));
|
CK((*filter->output_function)(0x8e, filter->data));
|
||||||
CK((*filter->output_function)(s1, filter->data));
|
CK((*filter->output_function)(s1, filter->data));
|
||||||
|
} else if (filter->to->no_encoding == mbfl_no_encoding_sjis2004 && (s1 >= 0xA1 && s1 <= 0xDF)) {
|
||||||
|
CK((*filter->output_function)(s1, filter->data));
|
||||||
} else {
|
} else {
|
||||||
CK(mbfl_filt_conv_illegal_output(c, filter));
|
CK(mbfl_filt_conv_illegal_output(c, filter));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue