ObjFW  Check-in [1e7e237e6e]

Overview
Comment:Ignore BOM at start of string.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1e7e237e6ee8d6673917a772fc0972f8d88aec706a58f6c04903ca1b4b4fd7e5
User & Date: js on 2010-11-11 20:52:27
Other Links: manifest | tags
Context
2010-11-11
21:55
OFBlock is now based on OFObject. check-in: 56393a3fbd user: js tags: trunk
20:52
Ignore BOM at start of string. check-in: 1e7e237e6e user: js tags: trunk
20:47
Add full blocks support for OS X. check-in: 1a7c408c7d user: js tags: trunk
Changes

Modified src/OFString.m from [6583af04e3] to [04e9fd7c64].

322
323
324
325
326
327
328






329
330
331
332
333
334
335
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341







+
+
+
+
+
+







	   length: (size_t)len
{
	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) {
			switch (of_string_check_utf8(str, length)) {
			case 1:

Modified tests/OFStringTests.m from [eb03c62ab2] to [5c859eec81].

104
105
106
107
108
109
110
111
112


113
114
115
116
117
118
119
104
105
106
107
108
109
110


111
112
113
114
115
116
117
118
119







-
-
+
+







	TEST(@"-[upper]", R([s[0] upper]) && [s[0] isEqual: @"3𝄞1€SÄT"] &&
	    R([s[1] upper]) && [s[1] isEqual: @"ABC"])

	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]) &&
	    [s[1] isEqual: @"testäöü"])