ObjFW  Diff

Differences From Artifact [7205f31b8d]:

To Artifact [6384f6bbc6]:


106
107
108
109
110
111
112


113
114
115
116
117
118
119
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121







+
+








extern bool _OFUnicodeToISO8859_2(const OFUnichar *, unsigned char *,
    size_t, bool);
extern bool _OFUnicodeToISO8859_3(const OFUnichar *, unsigned char *,
    size_t, bool);
extern bool _OFUnicodeToISO8859_15(const OFUnichar *, unsigned char *,
    size_t, bool);
extern bool _OFUnicodeToWindows1250(const OFUnichar *, unsigned char *,
    size_t, bool);
extern bool _OFUnicodeToWindows1251(const OFUnichar *, unsigned char *,
    size_t, bool);
extern bool _OFUnicodeToWindows1252(const OFUnichar *, unsigned char *,
    size_t, bool);
extern bool _OFUnicodeToCodepage437(const OFUnichar *, unsigned char *,
    size_t, bool);
extern bool _OFUnicodeToCodepage850(const OFUnichar *, unsigned char *,
168
169
170
171
172
173
174




175
176
177
178
179
180
181
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187







+
+
+
+







		encoding = OFStringEncodingISO8859_2;
	else if ([string isEqual: @"iso-8859-3"] ||
	    [string isEqual: @"iso_8859-3"])
		encoding = OFStringEncodingISO8859_3;
	else if ([string isEqual: @"iso-8859-15"] ||
	    [string isEqual: @"iso_8859-15"])
		encoding = OFStringEncodingISO8859_15;
	else if ([string isEqual: @"windows-1250"] ||
	    [string isEqual: @"cp1250"] || [string isEqual: @"cp-1250"] ||
	    [string isEqual: @"1250"])
		encoding = OFStringEncodingWindows1250;
	else if ([string isEqual: @"windows-1251"] ||
	    [string isEqual: @"cp1251"] || [string isEqual: @"cp-1251"] ||
	    [string isEqual: @"1251"])
		encoding = OFStringEncodingWindows1251;
	else if ([string isEqual: @"windows-1252"] ||
	    [string isEqual: @"cp1252"] || [string isEqual: @"cp-1252"] ||
	    [string isEqual: @"1252"])
215
216
217
218
219
220
221


222
223
224
225
226
227
228
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236







+
+







		return @"ISO 8859-1";
	case OFStringEncodingISO8859_2:
		return @"ISO 8859-2";
	case OFStringEncodingISO8859_3:
		return @"ISO 8859-3";
	case OFStringEncodingISO8859_15:
		return @"ISO 8859-15";
	case OFStringEncodingWindows1250:
		return @"Windows-1250";
	case OFStringEncodingWindows1251:
		return @"Windows-1251";
	case OFStringEncodingWindows1252:
		return @"Windows-1252";
	case OFStringEncodingCodepage437:
		return @"Codepage 437";
	case OFStringEncodingCodepage850:
1162
1163
1164
1165
1166
1167
1168













1169
1170
1171
1172
1173
1174
1175
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196







+
+
+
+
+
+
+
+
+
+
+
+
+








		if (!_OFUnicodeToISO8859_15(characters,
		    (unsigned char *)cString, length, lossy))
			@throw [OFInvalidEncodingException exception];

		cString[length] = '\0';

		return length;
#endif
#ifdef HAVE_WINDOWS_1250
	case OFStringEncodingWindows1250:
		if (length + 1 > maxLength)
			@throw [OFOutOfRangeException exception];

		if (!_OFUnicodeToWindows1250(characters,
		    (unsigned char *)cString, length, lossy))
			@throw [OFInvalidEncodingException exception];

		cString[length] = '\0';

		return length;
#endif
#ifdef HAVE_WINDOWS_1251
	case OFStringEncodingWindows1251:
		if (length + 1 > maxLength)
			@throw [OFOutOfRangeException exception];

1328
1329
1330
1331
1332
1333
1334

1335
1336
1337
1338
1339
1340
1341
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363







+








		break;
	case OFStringEncodingASCII:
	case OFStringEncodingISO8859_1:
	case OFStringEncodingISO8859_2:
	case OFStringEncodingISO8859_3:
	case OFStringEncodingISO8859_15:
	case OFStringEncodingWindows1250:
	case OFStringEncodingWindows1251:
	case OFStringEncodingWindows1252:
	case OFStringEncodingCodepage437:
	case OFStringEncodingCodepage850:
	case OFStringEncodingCodepage858:
	case OFStringEncodingMacRoman:
	case OFStringEncodingKOI8R:
1411
1412
1413
1414
1415
1416
1417

1418
1419
1420
1421
1422
1423
1424
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447







+








		return UTF8StringLength;
	case OFStringEncodingASCII:
	case OFStringEncodingISO8859_1:
	case OFStringEncodingISO8859_2:
	case OFStringEncodingISO8859_3:
	case OFStringEncodingISO8859_15:
	case OFStringEncodingWindows1250:
	case OFStringEncodingWindows1251:
	case OFStringEncodingWindows1252:
	case OFStringEncodingCodepage437:
	case OFStringEncodingCodepage850:
	case OFStringEncodingCodepage858:
	case OFStringEncodingMacRoman:
	case OFStringEncodingKOI8R: