encoding.c: Support the KOI8-R encoding.

This commit is contained in:
Reece H. Dunn
2017-03-29 07:49:48 +01:00
parent b8a1006dd8
commit 39f3ea54cf
3 changed files with 53 additions and 1 deletions
+27
View File
@@ -91,6 +91,32 @@ test_us_ascii_encoding()
destroy_text_decoder(decoder);
}
void
test_koi8_r_encoding()
{
printf("testing KOI8-R encoding\n");
assert(espeak_ng_EncodingFromName("KOI8-R") == ESPEAKNG_ENCODING_KOI8_R);
assert(espeak_ng_EncodingFromName("csKOI8R") == ESPEAKNG_ENCODING_KOI8_R);
espeak_ng_TEXT_DECODER *decoder = create_text_decoder();
assert(text_decoder_decode_string(decoder, "aG\x92\xA0\xDE", 5, ESPEAKNG_ENCODING_KOI8_R) == ENS_OK);
assert(text_decoder_eof(decoder) == 0);
assert(text_decoder_getc(decoder) == 'a');
assert(text_decoder_eof(decoder) == 0);
assert(text_decoder_getc(decoder) == 'G');
assert(text_decoder_eof(decoder) == 0);
assert(text_decoder_getc(decoder) == 0x92);
assert(text_decoder_eof(decoder) == 0);
assert(text_decoder_getc(decoder) == 0xA0);
assert(text_decoder_eof(decoder) == 0);
assert(text_decoder_getc(decoder) == 0x021a);
assert(text_decoder_eof(decoder) == 1);
destroy_text_decoder(decoder);
}
void
test_iso_8859_1_encoding()
{
@@ -555,6 +581,7 @@ main(int argc, char **argv)
test_unknown_encoding();
test_us_ascii_encoding();
test_koi8_r_encoding();
test_iso_8859_1_encoding();
test_iso_8859_2_encoding();