@@ -584,6 +584,17 @@ static size_t mb_iso2022jp_to_wchar(unsigned char **in, size_t *in_len, uint32_t
584
584
} else if (c < 0x80 ) {
585
585
* out ++ = c ;
586
586
} else if (c >= 0xA1 && c <= 0xDF ) {
587
+ /* GR-invoked Kana; "GR" stands for "graphics right" and refers to bytes
588
+ * with the MSB bit (in the context of ISO-2022 encoding).
589
+ *
590
+ * In this regard, Wikipedia states:
591
+ * "Other, older variants known as JIS7 and JIS8 build directly on the 7-bit and 8-bit
592
+ * encodings defined by JIS X 0201 and allow use of JIS X 0201 kana from G1 without
593
+ * escape sequences, using Shift Out and Shift In or setting the eighth bit
594
+ * (GR-invoked), respectively."
595
+ *
596
+ * Note that we support both the 'JIS7' use of 0xE/0xF Shift In/Shift Out codes
597
+ * and the 'JIS8' use of GR-invoked Kana */
587
598
* out ++ = 0xFEC0 + c ;
588
599
} else {
589
600
* out ++ = MBFL_BAD_INPUT ;
@@ -731,6 +742,13 @@ static void mb_wchar_to_jis(uint32_t *in, size_t len, mb_convert_buf *buf, bool
731
742
buf -> state = ASCII ;
732
743
}
733
744
out = mb_convert_buf_add (out , s );
745
+ } else if (s >= 0xA1 && s <= 0xDF ) {
746
+ if (buf -> state != JISX_0201_KANA ) {
747
+ MB_CONVERT_BUF_ENSURE (buf , out , limit , (len * 2 ) + 4 );
748
+ out = mb_convert_buf_add3 (out , 0x1B , '(' , 'I' );
749
+ buf -> state = JISX_0201_KANA ;
750
+ }
751
+ out = mb_convert_buf_add (out , s & 0x7F );
734
752
} else if (s < 0x8080 ) { /* JIS X 0208 */
735
753
if (buf -> state != JISX_0208 ) {
736
754
MB_CONVERT_BUF_ENSURE (buf , out , limit , (len * 2 ) + 5 );
0 commit comments