ObjFW  Check-in [7d29241068]

Overview
Comment:Actually, it's called charset in the header, not encoding.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7d29241068fd8341c7903385bd05032c916f33da840e6c2ce44a7da07d1faf55
User & Date: js on 2011-04-25 22:54:37
Other Links: manifest | tags
Context
2011-04-27
16:14
Small string optimization. check-in: 50a6d34eff user: js tags: trunk
2011-04-25
22:54
Actually, it's called charset in the header, not encoding. check-in: 7d29241068 user: js tags: trunk
22:50
Don't fall back to ISO-8859-1 in +[OFString stringWithContentsOfURL:].
This way, we can be sure to never have garbage.
check-in: c74d7dec0e user: js tags: trunk
Changes

Modified src/OFString.m from [1d7ba884bb] to [ac1b639bcb].

737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
		      statusCode: [result statusCode]];

	if (encoding == OF_STRING_ENCODING_AUTODETECT &&
	    (contentType = [[result headers] objectForKey: @"Content-Type"])) {
		contentType = [[contentType mutableCopy] autorelease];
		[contentType lower];

		if ([contentType hasSuffix: @"encoding=UTF-8"])
			encoding = OF_STRING_ENCODING_UTF_8;
		if ([contentType hasSuffix: @"encoding=iso-8859-1"])
			encoding = OF_STRING_ENCODING_ISO_8859_1;
		if ([contentType hasSuffix: @"encoding=iso-8859-15"])
			encoding = OF_STRING_ENCODING_ISO_8859_15;
		if ([contentType hasSuffix: @"encoding=windows-1252"])
			encoding = OF_STRING_ENCODING_WINDOWS_1252;
	}

	if (encoding == OF_STRING_ENCODING_AUTODETECT)
		encoding = OF_STRING_ENCODING_UTF_8;

	self = [[c alloc] initWithCString: (char*)[[result data] cArray]







|

|

|

|







737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
		      statusCode: [result statusCode]];

	if (encoding == OF_STRING_ENCODING_AUTODETECT &&
	    (contentType = [[result headers] objectForKey: @"Content-Type"])) {
		contentType = [[contentType mutableCopy] autorelease];
		[contentType lower];

		if ([contentType hasSuffix: @"charset=UTF-8"])
			encoding = OF_STRING_ENCODING_UTF_8;
		if ([contentType hasSuffix: @"charset=iso-8859-1"])
			encoding = OF_STRING_ENCODING_ISO_8859_1;
		if ([contentType hasSuffix: @"charset=iso-8859-15"])
			encoding = OF_STRING_ENCODING_ISO_8859_15;
		if ([contentType hasSuffix: @"charset=windows-1252"])
			encoding = OF_STRING_ENCODING_WINDOWS_1252;
	}

	if (encoding == OF_STRING_ENCODING_AUTODETECT)
		encoding = OF_STRING_ENCODING_UTF_8;

	self = [[c alloc] initWithCString: (char*)[[result data] cArray]