ObjFW  Check-in [dcf50eb53a]

Overview
Comment:Don't prepend a BOM when using -[unicodeString].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: dcf50eb53ac9f71b272d24d3eecbae68b601c5599095f71b7e2fd6827a60f885
User & Date: js on 2011-10-31 21:20:10
Other Links: manifest | tags
Context
2011-10-31
22:01
Assume big endian encoding for UTF16 if none is specified and no BOM. check-in: f412995e6a user: js tags: trunk
21:20
Don't prepend a BOM when using -[unicodeString]. check-in: dcf50eb53a user: js tags: trunk
21:19
Fix a missing const in tests. check-in: 3dc09e8fac user: js tags: trunk
Changes

Modified src/OFString.m from [7ae1259373] to [37713bd91c].

1873
1874
1875
1876
1877
1878
1879
1880

1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1873
1874
1875
1876
1877
1878
1879

1880
1881
1882
1883
1884
1885


1886
1887
1888
1889
1890
1891
1892







-
+





-
-








- (const of_unichar_t*)unicodeString
{
	OFObject *object = [[[OFObject alloc] init] autorelease];
	of_unichar_t *ret;
	size_t i, j;

	ret = [object allocMemoryForNItems: s->length + 2
	ret = [object allocMemoryForNItems: s->length + 1
				    ofSize: sizeof(of_unichar_t)];

	i = 0;
	j = 0;

	ret[j++] = 0xFEFF;

	while (i < s->cStringLength) {
		of_unichar_t c;
		size_t cLen;

		cLen = of_string_utf8_to_unicode(s->cString + i,
		    s->cStringLength - i, &c);

Modified tests/OFStringTests.m from [9f38334afc] to [4c3630eafa].

377
378
379
380
381
382
383
384

385
386
387
388
389
390
391
377
378
379
380
381
382
383

384
385
386
387
388
389
390
391







-
+







	EXPECT_EXCEPTION(@"Detect out of range in -[hexadecimalValue]",
	    OFOutOfRangeException,
	    [@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
	     @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
	    hexadecimalValue])

	TEST(@"-[unicodeString]", (ua = [@"fööbär🀺" unicodeString]) &&
	    !memcmp(ua, ucstr, 9 * sizeof(of_unichar_t)))
	    !memcmp(ua, ucstr + 1, sizeof(ucstr) - sizeof(of_unichar_t)))

	TEST(@"-[MD5Hash]", [[@"asdfoobar" MD5Hash]
	    isEqual: @"184dce2ec49b5422c7cfd8728864db4c"])

	TEST(@"-[SHA1Hash]", [[@"asdfoobar" SHA1Hash]
	    isEqual: @"f5f81ac0a8b5cbfdc4585ec1ad32e7b3a12b9b49"])