mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix legacy conversion filter for CP50220
This commit is contained in:
parent
1662f7f79f
commit
6938e35122
2 changed files with 11 additions and 0 deletions
|
@ -338,7 +338,11 @@ static int mbfl_filt_conv_wchar_cp50220(int c, mbfl_convert_filter *filter)
|
|||
if (filter->cache) {
|
||||
int s = mbfl_convert_kana(filter->cache, c, &consumed, NULL, mode);
|
||||
filter->cache = consumed ? 0 : c;
|
||||
/* Terrible hack to get CP50220 to emit error markers in the proper
|
||||
* position, not reordering them with subsequent characters */
|
||||
filter->filter_function = mbfl_filt_conv_wchar_cp50221;
|
||||
mbfl_filt_conv_wchar_cp50221(s, filter);
|
||||
filter->filter_function = mbfl_filt_conv_wchar_cp50220;
|
||||
} else if (c == 0) {
|
||||
/* This case has to be handled separately, since `filter->cache == 0` means
|
||||
* no codepoint is cached */
|
||||
|
|
|
@ -375,6 +375,13 @@ $converted = mb_convert_encoding("ab\x00", 'UTF-16BE', 'CP50220');
|
|||
if ($converted !== "\x00a\x00b\x00\x00")
|
||||
die("Bad handling of trailing null byte (got " . bin2hex($converted) . ")");
|
||||
|
||||
// Previously, the CP50220 implementation would reorder error markers with
|
||||
// subsequent characters
|
||||
mb_substitute_character(0x3F);
|
||||
$converted = mb_convert_encoding("\xff\xff\x00&", 'CP50220', 'UTF-16BE');
|
||||
if ($converted !== '?&')
|
||||
die("Bad handling of erroneous codepoint followed by good one (got " . bin2hex($converted) . ")");
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
ASCII support OK
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue