@@ -31,11 +31,11 @@ #import "asprintf.h" #import "unicode.h" static void apply_table(id self, Class isa, char **string, unsigned int *length, - BOOL is_utf8, const int16_t* const table[], const size_t table_size) + BOOL is_utf8, const of_unichar_t* const table[], const size_t table_size) { of_unichar_t c; of_unichar_t *ustr; size_t ulen, nlen, clen; size_t i, j, d; @@ -45,11 +45,12 @@ assert(table_size >= 1); uint8_t *p = (uint8_t*)*string + *length; while (--p >= (uint8_t*)*string) - *p += table[0][*p]; + if (table[0][*p]) + *p = table[0][*p]; return; } ulen = [self length]; @@ -66,12 +67,16 @@ if (clen == 0 || c > 0x10FFFF) { [self freeMemory: ustr]; @throw [OFInvalidEncodingException newWithClass: isa]; } - if (c >> 8 < table_size) - c += table[c >> 8][c & 0xFF]; + if (c >> 8 < table_size) { + of_unichar_t tc = table[c >> 8][c & 0xFF]; + + if (tc) + c = tc; + } ustr[j++] = c; if (c < 0x80) nlen++; else if (c < 0x800)