Index: src/OFUTF8String.m ================================================================== --- src/OFUTF8String.m +++ src/OFUTF8String.m @@ -370,23 +370,26 @@ unsigned char character = (unsigned char)cString[i]; OFUnichar unichar; char buffer[4]; size_t byteLength; - if (character < tableOffset) { - _s->cString[j++] = cString[i]; - continue; - } - - unichar = table[character - tableOffset]; + if (character >= tableOffset) + unichar = table[character - tableOffset]; + else + unichar = character; if (unichar == 0xFFFF) @throw [OFInvalidEncodingException exception]; + + if (unichar < 0x7F) { + _s->cString[j++] = (char)unichar; + continue; + } _s->isUTF8 = true; + byteLength = _OFUTF8StringEncode(unichar, buffer); - if (byteLength == 0) @throw [OFInvalidEncodingException exception]; _s->cStringLength += byteLength - 1; _s->cString = OFResizeMemory(_s->cString, Index: tests/OFStringTests.m ================================================================== --- tests/OFStringTests.m +++ tests/OFStringTests.m @@ -263,12 +263,13 @@ #ifdef HAVE_ISO_8859_15 - (void)testStringWithCStringEncodingISO8859_15 { OTAssertEqualObjects([self.stringClass - stringWithCString: "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE" - encoding: OFStringEncodingISO8859_15], @"€ŠšŽžŒœŸ"); + stringWithCString: "a\x80\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE" + encoding: OFStringEncodingISO8859_15], + @"a\xC2\x80€ŠšŽžŒœŸ"); } #endif #ifdef HAVE_WINDOWS_1250 - (void)testStringWithCStringEncodingWindows1250