lib/core: provide default codec-aware read_char
authorLucas Bajolet <lucas.bajolet@gmail.com>
Mon, 7 May 2018 14:45:21 +0000 (10:45 -0400)
committerLucas Bajolet <lucas.bajolet@gmail.com>
Thu, 10 May 2018 20:48:30 +0000 (16:48 -0400)
commit6f706a41ccad5b0ba930eff7f08957f0b77ee215
tree6136054e14a270163ed1a0747f29c48daf2ed10f
parent4f08e0f132c283652c45ee43f5be66c37041333d
lib/core: provide default codec-aware read_char

Previous implementations of read_char were unaware of codec issues, and
used to read a byte and convert it to a code point.

For ASCII characters this was enough, but once unicode characters were
read on a char-by-char basis, wrong characters would appear.

This commit fixes this issue by using the Codec API to read a character
intelligently, and properly support multibyte encodings.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>
lib/core/stream.nit
tests/sav/test_read_char.res [new file with mode: 0644]
tests/sav/test_read_char_alt1.res [new file with mode: 0644]
tests/test_read_char.nit [new file with mode: 0644]