@@ -44,18 +44,19 @@ size_t i; for (i = 0; i < length; i++) { of_unichar_t c = input[i]; - if OF_UNLIKELY ((c >= 0x80 && c <= 0x9F) || c > 0xFFFF) { - if (lossy) - output[i] = '?'; - else - return false; - } - if OF_UNLIKELY (c > 0xFF) { + if OF_UNLIKELY (c > 0xFFFF) { + if (lossy) { + output[i] = '?'; + continue; + } else + return false; + } + switch ((of_char16_t)c) { case 0x20AC: output[i] = 0x80; break; case 0x201A: @@ -142,11 +143,18 @@ else return false; break; } - } else - output[i] = (uint8_t)c; + } else { + if OF_UNLIKELY (c >= 0x80 && c <= 0x9F) { + if (lossy) + output[i] = '?'; + else + return false; + } else + output[i] = (uint8_t)c; + } } return true; }