Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -324,10 +324,16 @@ self = [super init]; @try { size_t i, j; const uint16_t *table; + + if (encoding == OF_STRING_ENCODING_UTF_8 && + len >= 3 && !memcmp(str, "\xEF\xBB\xBF", 3)) { + str += 3; + len -= 3; + } string = [self allocMemoryWithSize: len + 1]; length = len; if (encoding == OF_STRING_ENCODING_UTF_8) { Index: tests/OFStringTests.m ================================================================== --- tests/OFStringTests.m +++ tests/OFStringTests.m @@ -106,12 +106,12 @@ TEST(@"-[lower]", R([s[0] lower]) && [s[0] isEqual: @"3𝄞1€sät"] && R([s[1] lower]) && [s[1] isEqual: @"abc"]) TEST(@"+[stringWithCString:length:]", - (s[0] = [OFMutableString stringWithCString: "foobar" - length: 3]) && + (s[0] = [OFMutableString stringWithCString: "\xEF\xBB\xBF" "foobar" + length: 6]) && [s[0] isEqual: @"foo"]) TEST(@"+[stringWithContentsOfFile:encoding]", (s[1] = [OFString stringWithContentsOfFile: @"testfile.txt" encoding: OF_STRING_ENCODING_ISO_8859_1]) &&