269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
- (instancetype)initWithStringRepresentation: (OFString *)string
{
self = [super init];
@try {
size_t count = [string
cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII];
const char *cString;
if (count % 2 != 0)
@throw [OFInvalidFormatException exception];
count /= 2;
_items = of_alloc(count, 1);
_count = count;
_itemSize = 1;
_freeWhenDone = true;
cString = [string
cStringWithEncoding: OF_STRING_ENCODING_ASCII];
for (size_t i = 0; i < count; i++) {
uint8_t c1 = cString[2 * i];
uint8_t c2 = cString[2 * i + 1];
uint8_t byte;
if (c1 >= '0' && c1 <= '9')
|
|
|
<
|
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
- (instancetype)initWithStringRepresentation: (OFString *)string
{
self = [super init];
@try {
size_t count = [string
cStringLengthWithEncoding: OFStringEncodingASCII];
const char *cString;
if (count % 2 != 0)
@throw [OFInvalidFormatException exception];
count /= 2;
_items = of_alloc(count, 1);
_count = count;
_itemSize = 1;
_freeWhenDone = true;
cString = [string cStringWithEncoding: OFStringEncodingASCII];
for (size_t i = 0; i < count; i++) {
uint8_t c1 = cString[2 * i];
uint8_t c2 = cString[2 * i + 1];
uint8_t byte;
if (c1 >= '0' && c1 <= '9')
|
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
self = [OFMutableData alloc];
}
self = [(OFMutableData *)self initWithCapacity: string.length / 3];
@try {
if (!of_base64_decode((OFMutableData *)self,
[string cStringWithEncoding: OF_STRING_ENCODING_ASCII],
[string cStringLengthWithEncoding:
OF_STRING_ENCODING_ASCII]))
@throw [OFInvalidFormatException exception];
} @catch (id e) {
[self release];
@throw e;
}
if (!mutable)
|
|
|
<
|
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
self = [OFMutableData alloc];
}
self = [(OFMutableData *)self initWithCapacity: string.length / 3];
@try {
if (!of_base64_decode((OFMutableData *)self,
[string cStringWithEncoding: OFStringEncodingASCII],
[string cStringLengthWithEncoding: OFStringEncodingASCII]))
@throw [OFInvalidFormatException exception];
} @catch (id e) {
[self release];
@throw e;
}
if (!mutable)
|