Skip to content

Commit 6e9c838

Browse files
committed
CP5022{0,1,2}: convert characters in ku 0x2D (13th row) correctly
Essentially, CP5022{0,1,2} are to CP932 as ISO-2022-JP is to Shift-JIS. As Shift-JIS and ISO-2022-JP both encode characters from the JIS X 0208 charset, CP932 and CP5022x both encode characters from JIS X 0208 _plus_ extra characters added as MicroSoft vendor extensions. Among the added characters are a number of symbols which MS put in the 13th row of the 94x94 character table. (In JIS X 0208, that row is empty.) mbfilter_cp50220x.c had an `if` clause which was intended to handle the conversion of characters in that 13th row, but it was dead code, as the previous clause was always true in those cases. The solution is to reverse the order of those two clauses (just as they already appeared in mbfilter_cp932.c).
1 parent cdd0724 commit 6e9c838

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/mbstring/libmbfl/filters/mbfilter_cp5022x.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ mbfl_filt_conv_jis_ms_wchar(int c, mbfl_convert_filter *filter)
247247
if (c > 0x20 && c < 0x7f) {
248248
s = (c1 - 0x21)*94 + c - 0x21;
249249
if (filter->status == 0x80) {
250-
if (s >= 0 && s < jisx0208_ucs_table_size) {
251-
w = jisx0208_ucs_table[s];
252-
} else if (s >= cp932ext1_ucs_table_min && s < cp932ext1_ucs_table_max) {
250+
if (s >= cp932ext1_ucs_table_min && s < cp932ext1_ucs_table_max) {
253251
w = cp932ext1_ucs_table[s - cp932ext1_ucs_table_min];
252+
} else if (s >= 0 && s < jisx0208_ucs_table_size) {
253+
w = jisx0208_ucs_table[s];
254254
} else if (s >= cp932ext2_ucs_table_min && s < cp932ext2_ucs_table_max) {
255255
w = cp932ext2_ucs_table[s - cp932ext2_ucs_table_min];
256256
} else if (s >= cp932ext3_ucs_table_min && s < cp932ext3_ucs_table_max) {

0 commit comments

Comments
 (0)