Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -248,11 +248,15 @@ { if (string == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; - [self appendCString: [string cString]]; + [self appendCStringWithoutUTF8Checking: [string cString] + length: [string cStringLength]]; + + if (string->s->isUTF8) + s->isUTF8 = YES; } - (void)appendFormat: (OFConstantString*)format, ... { va_list arguments; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -580,37 +580,18 @@ - initWithString: (OFString*)string { self = [super init]; @try { - const char *cString; - s = [self allocMemoryWithSize: sizeof(*s)]; memset(s, 0, sizeof(*s)); - cString = [string cString]; s->cStringLength = [string cStringLength]; - - switch (of_string_check_utf8(cString, s->cStringLength)) { - case 1: - s->isUTF8 = YES; - break; - case -1:; - @throw [OFInvalidEncodingException newWithClass: isa]; - } - - if ((s->cString = strdup(cString)) == NULL) - @throw [OFOutOfMemoryException - newWithClass: isa - requestedSize: s->cStringLength + 1]; - - @try { - [self addMemoryToPool: s->cString]; - } @catch (id e) { - free(s->cString); - @throw e; - } + s->isUTF8 = string->s->isUTF8; + + s->cString = [self allocMemoryWithSize: s->cStringLength + 1]; + memcpy(s->cString, [string cString], s->cStringLength + 1); } @catch (id e) { [self release]; @throw e; }