527
528
529
530
531
532
533
534
535
536
537
538
539
540
|
if (length <= i + 1)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
nextCharacter = (swap
? OF_BSWAP16(string[i + 1])
: string[i + 1]);
character = (((character & 0x3FF) << 10) |
(nextCharacter & 0x3FF)) + 0x10000;
i++;
s->cStringLength--;
s->length--;
}
|
>
>
>
>
>
|
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
|
if (length <= i + 1)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
nextCharacter = (swap
? OF_BSWAP16(string[i + 1])
: string[i + 1]);
if ((nextCharacter & 0xFC00) != 0xDC00)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
character = (((character & 0x3FF) << 10) |
(nextCharacter & 0x3FF)) + 0x10000;
i++;
s->cStringLength--;
s->length--;
}
|
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
|
if (cLen == 0 || c > 0x10FFFF)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
ret[j++] = c;
i += cLen;
}
return ret;
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block
{
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
|
if (cLen == 0 || c > 0x10FFFF)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
ret[j++] = c;
i += cLen;
}
return ret;
}
- (const of_unichar_t*)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder
{
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];
i = j = 0;
while (i < s->cStringLength) {
of_unichar_t c;
size_t cLen;
cLen = of_string_utf8_decode(s->cString + i,
s->cStringLength - i, &c);
if (cLen == 0 || c > 0x10FFFF)
@throw [OFInvalidEncodingException
exceptionWithClass: [self class]];
if (byteOrder != OF_BYTE_ORDER_NATIVE)
ret[j++] = OF_BSWAP32(c);
else
ret[j++] = c;
i += cLen;
}
ret[j] = 0;
return ret;
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block
{
|