@@ -401,26 +401,26 @@ } return self; } -- initWithUnicodeString: (const of_unichar_t*)string - byteOrder: (of_byte_order_t)byteOrder - length: (size_t)length +- initWithCharacters: (const of_unichar_t*)characters + length: (size_t)length + byteOrder: (of_byte_order_t)byteOrder { self = [super init]; @try { size_t i, j = 0; BOOL swap = NO; - if (length > 0 && *string == 0xFEFF) { - string++; + if (length > 0 && *characters == 0xFEFF) { + characters++; length--; - } else if (length > 0 && *string == 0xFFFE0000) { + } else if (length > 0 && *characters == 0xFFFE0000) { swap = YES; - string++; + characters++; length--; } else if (byteOrder != OF_BYTE_ORDER_NATIVE) swap = YES; s = &s_store; @@ -430,11 +430,11 @@ s->length = length; for (i = 0; i < length; i++) { char buffer[4]; size_t characterLen = of_string_utf8_encode( - (swap ? OF_BSWAP32(string[i]) : string[i]), + (swap ? OF_BSWAP32(characters[i]) : characters[i]), buffer); switch (characterLen) { case 1: s->cString[j++] = buffer[0]; @@ -484,12 +484,12 @@ return self; } - initWithUTF16String: (const uint16_t*)string - byteOrder: (of_byte_order_t)byteOrder length: (size_t)length + byteOrder: (of_byte_order_t)byteOrder { self = [super init]; @try { size_t i, j = 0; @@ -951,17 +951,17 @@ - (void)getCharacters: (of_unichar_t*)buffer inRange: (of_range_t)range { /* TODO: Could be slightly optimized */ void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *unicodeString = [self unicodeString]; + const of_unichar_t *characters = [self characters]; if (range.length > SIZE_MAX - range.location || range.location + range.length > s->length) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; - memcpy(buffer, unicodeString + range.location, + memcpy(buffer, characters + range.location, range.length * sizeof(of_unichar_t)); objc_autoreleasePoolPop(pool); } @@ -1246,18 +1246,18 @@ length: 1]; return @"."; } -- (const of_unichar_t*)unicodeString +- (const of_unichar_t*)characters { OFObject *object = [[[OFObject alloc] init] autorelease]; of_unichar_t *ret; size_t i, j; ret = [object allocMemoryWithSize: sizeof(of_unichar_t) - count: s->length + 1]; + count: s->length]; i = j = 0; while (i < s->cStringLength) { of_unichar_t c; @@ -1272,12 +1272,10 @@ ret[j++] = c; i += cLen; } - ret[j] = 0; - return ret; } #ifdef OF_HAVE_BLOCKS - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block