ObjFW  Check-in [238d47a1d6]

Overview
Comment:Allow iso_8859-* spellings for encoding
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 238d47a1d6fe115af3aafa623f6d6bb9d1875fddaf0cf58c5860ff266a7b356e
User & Date: js on 2017-01-17 01:20:30
Other Links: manifest | tags
Context
2017-01-17
03:23
Add ISO-8859-2 check-in: 7a27ce7b0b user: js tags: trunk
01:20
Allow iso_8859-* spellings for encoding check-in: 238d47a1d6 user: js tags: trunk
2017-01-16
03:28
OFLocalization: Accept a DOS codepage as well check-in: b240b71cec user: js tags: trunk
Changes

Modified src/OFHTTPResponse.m from [c6e5820a6c] to [f8cf1ed9b2].

109
110
111
112
113
114
115
116

117
118

119
120
121
122
123
124
125

	if (encoding == OF_STRING_ENCODING_AUTODETECT &&
	    (contentType = [_headers objectForKey: @"Content-Type"]) != nil) {
		contentType = [contentType lowercaseString];

		if ([contentType hasSuffix: @"charset=utf-8"])
			encoding = OF_STRING_ENCODING_UTF_8;
		else if ([contentType hasSuffix: @"charset=iso-8859-1"])

			encoding = OF_STRING_ENCODING_ISO_8859_1;
		else if ([contentType hasSuffix: @"charset=iso-8859-15"])

			encoding = OF_STRING_ENCODING_ISO_8859_15;
		else if ([contentType hasSuffix: @"charset=windows-1251"] ||
		    [contentType hasSuffix: @"charset=cp1251"] ||
		    [contentType hasSuffix: @"charset=cp-1251"])
			encoding = OF_STRING_ENCODING_WINDOWS_1251;
		else if ([contentType hasSuffix: @"charset=windows-1252"] ||
		    [contentType hasSuffix: @"charset=cp1252"] ||







|
>

|
>







109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

	if (encoding == OF_STRING_ENCODING_AUTODETECT &&
	    (contentType = [_headers objectForKey: @"Content-Type"]) != nil) {
		contentType = [contentType lowercaseString];

		if ([contentType hasSuffix: @"charset=utf-8"])
			encoding = OF_STRING_ENCODING_UTF_8;
		else if ([contentType hasSuffix: @"charset=iso-8859-1"] ||
		    [contentType hasSuffix: @"charset=iso_8859-1"])
			encoding = OF_STRING_ENCODING_ISO_8859_1;
		else if ([contentType hasSuffix: @"charset=iso-8859-15"] ||
		    [contentType hasSuffix: @"charset=iso_8859-15"])
			encoding = OF_STRING_ENCODING_ISO_8859_15;
		else if ([contentType hasSuffix: @"charset=windows-1251"] ||
		    [contentType hasSuffix: @"charset=cp1251"] ||
		    [contentType hasSuffix: @"charset=cp-1251"])
			encoding = OF_STRING_ENCODING_WINDOWS_1251;
		else if ([contentType hasSuffix: @"charset=windows-1252"] ||
		    [contentType hasSuffix: @"charset=cp1252"] ||

Modified src/OFLocalization.m from [2eb0e472df] to [e47e440130].

99
100
101
102
103
104
105
106

107
108
109

110
111
112
113
114
115
116
			if (strcmp(tmp, "utf8") == 0 ||
			    strcmp(tmp, "utf-8") == 0)
				_encoding = OF_STRING_ENCODING_UTF_8;
			else if (strcmp(tmp, "ascii") == 0 ||
			    strcmp(tmp, "us-ascii") == 0)
				_encoding = OF_STRING_ENCODING_ASCII;
			else if (strcmp(tmp, "iso8859-1") == 0 ||
			    strcmp(tmp, "iso-8859-1") == 0)

				_encoding = OF_STRING_ENCODING_ISO_8859_1;
			else if (strcmp(tmp, "iso8859-15") == 0 ||
			    strcmp(tmp, "iso-8859-15") == 0)

				_encoding = OF_STRING_ENCODING_ISO_8859_15;
			/* Windows and DJGPP use a codepage */
			else if (strcmp(tmp, "1251") == 0)
				_encoding = OF_STRING_ENCODING_WINDOWS_1251;
			else if (strcmp(tmp, "1252") == 0)
				_encoding = OF_STRING_ENCODING_WINDOWS_1252;
			else if (strcmp(tmp, "437") == 0)







|
>


|
>







99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
			if (strcmp(tmp, "utf8") == 0 ||
			    strcmp(tmp, "utf-8") == 0)
				_encoding = OF_STRING_ENCODING_UTF_8;
			else if (strcmp(tmp, "ascii") == 0 ||
			    strcmp(tmp, "us-ascii") == 0)
				_encoding = OF_STRING_ENCODING_ASCII;
			else if (strcmp(tmp, "iso8859-1") == 0 ||
			    strcmp(tmp, "iso-8859-1") == 0 ||
			    strcmp(tmp, "iso_8859-1") == 0)
				_encoding = OF_STRING_ENCODING_ISO_8859_1;
			else if (strcmp(tmp, "iso8859-15") == 0 ||
			    strcmp(tmp, "iso-8859-15") == 0 ||
			    strcmp(tmp, "iso_8859-15") == 0)
				_encoding = OF_STRING_ENCODING_ISO_8859_15;
			/* Windows and DJGPP use a codepage */
			else if (strcmp(tmp, "1251") == 0)
				_encoding = OF_STRING_ENCODING_WINDOWS_1251;
			else if (strcmp(tmp, "1252") == 0)
				_encoding = OF_STRING_ENCODING_WINDOWS_1252;
			else if (strcmp(tmp, "437") == 0)

Modified src/OFXMLParser.m from [469c7272f8] to [a54e16b4ae].

462
463
464
465
466
467
468
469

470
471
472

473
474
475
476
477
478
479
			}

			if ([attribute isEqual: @"encoding"]) {
				[value lowercase];

				if ([value isEqual: @"utf-8"])
					_encoding = OF_STRING_ENCODING_UTF_8;
				else if ([value isEqual: @"iso-8859-1"])

					_encoding =
					    OF_STRING_ENCODING_ISO_8859_1;
				else if ([value isEqual: @"iso-8859-15"])

					_encoding =
					    OF_STRING_ENCODING_ISO_8859_15;
				else if ([value isEqual: @"windows-1251"] ||
				    [value isEqual: @"cp1251"] ||
				    [value isEqual: @"cp-1251"])
					_encoding =
					    OF_STRING_ENCODING_WINDOWS_1251;







|
>


|
>







462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
			}

			if ([attribute isEqual: @"encoding"]) {
				[value lowercase];

				if ([value isEqual: @"utf-8"])
					_encoding = OF_STRING_ENCODING_UTF_8;
				else if ([value isEqual: @"iso-8859-1"] ||
				    [value isEqual: @"iso_8859-1"])
					_encoding =
					    OF_STRING_ENCODING_ISO_8859_1;
				else if ([value isEqual: @"iso-8859-15"] ||
				    [value isEqual: @"iso_8859-15"])
					_encoding =
					    OF_STRING_ENCODING_ISO_8859_15;
				else if ([value isEqual: @"windows-1251"] ||
				    [value isEqual: @"cp1251"] ||
				    [value isEqual: @"cp-1251"])
					_encoding =
					    OF_STRING_ENCODING_WINDOWS_1251;