From 3b641430ee35ce112340c37349b06221f22d218f Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 30 Jul 2009 07:28:32 -0400 Subject: [PATCH] Change NSXMLElementAdditions to use UTF8 strings when converting, rather than ASCII. --- Source/NSXMLElementAdditions.m | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/NSXMLElementAdditions.m b/Source/NSXMLElementAdditions.m index 9642ae2..9d37762 100644 --- a/Source/NSXMLElementAdditions.m +++ b/Source/NSXMLElementAdditions.m @@ -71,20 +71,22 @@ // base64 encoded data if ([[[self attributeForName:@"encoding"] stringValue] isEqualToString:@"base64"]) { - char* str = (char*)[[self stringValue] cStringUsingEncoding:NSASCIIStringEncoding]; - int strlen = [[self stringValue] lengthOfBytesUsingEncoding:NSASCIIStringEncoding]; + const char* str = [[self stringValue] UTF8String]; + int strlen = [[self stringValue] length]; char* data; size_t datalen; if (!base64_decode_alloc(str, strlen, &data, &datalen)) + NSLog(@"error in converting %@ from base64", self); + + NSString* ret = nil; + if (data) { - NSLog(@"error in converting %@ to base64", self); + ret = [NSString stringWithUTF8String:data]; + free(data); } - NSString* ret = [NSString stringWithCString:data length:datalen]; - free(data); - return ret; } -- 2.43.5