Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -30,10 +30,11 @@ /** * \brief The encoding of a string. */ typedef enum of_string_encoding_t { OF_STRING_ENCODING_UTF_8, + OF_STRING_ENCODING_ASCII, OF_STRING_ENCODING_ISO_8859_1, OF_STRING_ENCODING_ISO_8859_15, OF_STRING_ENCODING_WINDOWS_1252, OF_STRING_ENCODING_AUTODETECT = 0xFF } of_string_encoding_t; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -479,14 +479,19 @@ memset(s, 0, sizeof(*s)); s->cString = [self allocMemoryWithSize: cStringLength + 1]; s->cStringLength = cStringLength; - if (encoding == OF_STRING_ENCODING_UTF_8) { + if (encoding == OF_STRING_ENCODING_UTF_8 || + encoding == OF_STRING_ENCODING_ASCII) { switch (of_string_check_utf8(cString, cStringLength, &s->length)) { case 1: + if (encoding == OF_STRING_ENCODING_ASCII) + @throw [OFInvalidEncodingException + newWithClass: isa]; + s->isUTF8 = YES; break; case -1: @throw [OFInvalidEncodingException newWithClass: isa];