From a714c0554b67eb106dc19511be89d15fb3cf0b8d Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Thu, 30 Mar 2017 23:35:00 +0100 Subject: [PATCH] encoding.c: Use a codepage table to implement ISO-8859-1. --- src/libespeak-ng/encoding.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/libespeak-ng/encoding.c b/src/libespeak-ng/encoding.c index ecd4cb20..df0ba793 100644 --- a/src/libespeak-ng/encoding.c +++ b/src/libespeak-ng/encoding.c @@ -166,6 +166,27 @@ struct espeak_ng_TEXT_DECODER_ const uint16_t *codepage; }; +// Reference: http://www.iana.org/go/rfc1345 +// Reference: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-1.TXT +static const uint16_t ISO_8859_1[0x80] = { + 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, // 80 + 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f, // 88 + 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, // 90 + 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f, // 98 + 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, // a0 + 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, // a8 + 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, // b0 + 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, // b8 + 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, // c0 + 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8 + 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, // d0 + 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df, // d8 + 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, // e0 + 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8 + 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, // f0 + 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff, // f8 +}; + // Reference: http://www.iana.org/go/rfc1345 // Reference: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-2.TXT static const uint16_t ISO_8859_2[0x80] = { @@ -503,14 +524,6 @@ string_decoder_getc_us_ascii(espeak_ng_TEXT_DECODER *decoder) return (c >= 0x80) ? 0xFFFD : c; } -// Reference: http://www.iana.org/go/rfc1345 -// Reference: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-1.TXT -static uint32_t -string_decoder_getc_iso_8859_1(espeak_ng_TEXT_DECODER *decoder) -{ - return *decoder->current++; -} - static uint32_t string_decoder_getc_codepage(espeak_ng_TEXT_DECODER *decoder) { @@ -598,7 +611,7 @@ typedef struct static const encoding_t string_decoders[] = { { NULL, NULL }, { string_decoder_getc_us_ascii, NULL }, - { string_decoder_getc_iso_8859_1, NULL }, + { string_decoder_getc_codepage, ISO_8859_1 }, { string_decoder_getc_codepage, ISO_8859_2 }, { string_decoder_getc_codepage, ISO_8859_3 }, { string_decoder_getc_codepage, ISO_8859_4 },