Skip to content

Commit eda73a5

Browse files
committed
Don't mangle non-Japanese chars which appear after a 'combining' kana in SJIS-2004
Unicode has 'combining' characters which join with another following character. Japanese hiragana and katakana with the 'two dots' voice mark can be represented in this way, with one Unicode character for the 'base' kana and another one which adds the voice mark. In SJIS-2004, however, there are dedicated characters for voiced and unvoiced kana. So some special checks are done to identify sequences of Unicode characters which need to be 'collapsed' into a single SJIS-2004 character. If a kana is immediately followed by some other unrelated character, like a Cyrillic letter, then the cached kana should be output 'as is' and we proceed with encoding the unrelated character. When doing this, though, we need to re-initialize local variables, or else the unrelated character will be mangled in some cases.
1 parent 2f98bd8 commit eda73a5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/mbstring/libmbfl/filters/mbfilter_sjis_2004.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,10 @@ int mbfl_filt_conv_jis2004_wchar_flush(mbfl_convert_filter *filter)
485485
int
486486
mbfl_filt_conv_wchar_jis2004(int c, mbfl_convert_filter *filter) {
487487
int k;
488-
int c1, c2, s1 = 0, s2;
488+
int c1, c2, s1, s2;
489489

490490
retry:
491-
491+
s1 = 0;
492492
/* check for 1st char of combining characters */
493493
if ((filter->status & 0xf)== 0 && (
494494
c == 0x00E6 ||

0 commit comments

Comments
 (0)