diff --git a/src/coding.c b/src/coding.c index 35f85052c98..a7b040e2712 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7423,10 +7423,23 @@ decode_coding (struct coding_system *coding) while (nbytes-- > 0) { - int c = *src++; + int c; - if (c & 0x80) - c = BYTE8_TO_CHAR (c); + /* Copy raw bytes in their 2-byte forms from multibyte + text as single characters. */ + if (coding->src_multibyte + && CHAR_BYTE8_HEAD_P (*src) && nbytes > 0) + { + c = STRING_CHAR_ADVANCE (src); + nbytes--; + } + else + { + c = *src++; + + if (c & 0x80) + c = BYTE8_TO_CHAR (c); + } coding->charbuf[coding->charbuf_used++] = c; } produce_chars (coding, Qnil, 1);