ObjFW  Diff

Differences From Artifact [0f58e25244]:

To Artifact [f0fd5cc4db]:


91
92
93
94
95
96
97


98
99
100
101
102
103
104
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106







+
+








extern bool of_unicode_to_iso_8859_15(const of_unichar_t*, uint8_t*, size_t,
    bool);
extern bool of_unicode_to_windows_1252(const of_unichar_t*, uint8_t*, size_t,
    bool);
extern bool of_unicode_to_codepage_437(const of_unichar_t*, uint8_t*, size_t,
    bool);
extern bool of_unicode_to_codepage_850(const of_unichar_t*, uint8_t*, size_t,
    bool);

/* References for static linking */
void
_references_to_categories_of_OFString(void)
{
	_OFString_CryptoHashing_reference = 1;
	_OFString_JSONValue_reference = 1;
1118
1119
1120
1121
1122
1123
1124











1125
1126
1127
1128
1129
1130
1131
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144







+
+
+
+
+
+
+
+
+
+
+








		if (!of_unicode_to_codepage_437(characters, (uint8_t*)cString,
		    length, lossy))
			@throw [OFInvalidEncodingException exception];

		cString[length] = '\0';

		return length;
	case OF_STRING_ENCODING_CODEPAGE_850:
		if (length + 1 > maxLength)
			@throw [OFOutOfRangeException exception];

		if (!of_unicode_to_codepage_850(characters, (uint8_t*)cString,
		    length, lossy))
			@throw [OFInvalidEncodingException exception];

		cString[length] = '\0';

		return length;
	default:
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];
	}
}

1176
1177
1178
1179
1180
1181
1182

1183
1184
1185
1186
1187
1188
1189
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203







+








		break;
	case OF_STRING_ENCODING_ASCII:
	case OF_STRING_ENCODING_ISO_8859_1:
	case OF_STRING_ENCODING_ISO_8859_15:
	case OF_STRING_ENCODING_WINDOWS_1252:
	case OF_STRING_ENCODING_CODEPAGE_437:
	case OF_STRING_ENCODING_CODEPAGE_850:
		cString = [object allocMemoryWithSize: length + 1];

		[self OF_getCString: cString
			  maxLength: length + 1
			   encoding: encoding
			      lossy: lossy];

1240
1241
1242
1243
1244
1245
1246

1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268







+








		return UTF8StringLength;
	case OF_STRING_ENCODING_ASCII:
	case OF_STRING_ENCODING_ISO_8859_1:
	case OF_STRING_ENCODING_ISO_8859_15:
	case OF_STRING_ENCODING_WINDOWS_1252:
	case OF_STRING_ENCODING_CODEPAGE_437:
	case OF_STRING_ENCODING_CODEPAGE_850:
		return [self length];
	default:
		@throw [OFInvalidEncodingException exception];
	}
}

- (size_t)UTF8StringLength