134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Even though cStringLength can change, length cannot, therefore no
* need to change it.
*/
}
- (void)setToCString: (const char*)newCString
{
size_t newCStringLength = strlen(newCString);
size_t newLength;
if (newCStringLength >= 3 && !memcmp(newCString, "\xEF\xBB\xBF", 3)) {
newCString += 3;
newCStringLength -= 3;
}
switch (of_string_check_utf8(newCString, newCStringLength,
&newLength)) {
case 0:
s->isUTF8 = NO;
break;
case 1:
s->isUTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException newWithClass: isa];
}
[self freeMemory: s->cString];
s->cStringLength = newCStringLength;
s->length = newLength;
s->cString = [self allocMemoryWithSize: newCStringLength + 1];
memcpy(s->cString, newCString, newCStringLength + 1);
}
- (void)appendCString: (const char*)cString
{
size_t cStringLength = strlen(cString);
size_t length;
if (cStringLength >= 3 && !memcmp(cString, "\xEF\xBB\xBF", 3)) {
cString += 3;
|