Re: Base-64 decode (was Property List Editor)
Re: Base-64 decode (was Property List Editor)
- Subject: Re: Base-64 decode (was Property List Editor)
- From: Steven Kramer <email@hidden>
- Date: Thu, 9 Jun 2005 18:43:55 +0200
I used this as a quick hack. It uses the property list base 64 decoder.
I sneakily insert the base 64 string into an XML serialization of an
empty property list and then decode the property list. My data is
always very small, so this works for me.
NSData* DecodeBase64 (NSString* inBase64)
{
NSMutableData* data = [[[NSMutableData alloc] init] autorelease];
data = [[[NSPropertyListSerialization dataFromPropertyList: data
format: NSPropertyListXMLFormat_v1_0 errorDescription: nil]
mutableCopy] autorelease];
char nul = 0;
[data appendBytes: &nul length: 1];
NSMutableString* plist = [NSMutableString stringWithUTF8String:
reinterpret_cast < const char* > ([data bytes])];
[plist replaceOccurrencesOfString: @"<data>" withString: [@"<data>"
stringByAppendingString: inBase64] options: 0 range: NSMakeRange (0,
[plist length])];
data = [[[NSPropertyListSerialization propertyListFromData: [NSData
dataWithBytes: [plist UTF8String] length: [plist length]]
mutabilityOption:NSPropertyListImmutable format: nil errorDescription:
nil] mutableCopy] autorelease];
return data;
}
Regards,
Steven Kramer
--
email@hidden
http://www.sprintteam.nl/
Op 8-jun-05 om 18:49 heeft Graham Jones het volgende geschreven:
Hi Dave,
Thanks again for the quick response. Boy, you'd think there was an
easier
way, like an existing Objective-C method or shell script, given that
this is
Apple's standard encoding for data in plist files.
I tried downloading the extensions for the method you found ( Kyla's
page at
http://www.cpinternet.com/~em002400/CocoaProgramming.html ) but I am
having
trouble getting them to work in my Applescript Studio app.
Do you (or anyone else) know of an easier way to decode Base-64, or
how I
can get these to work in AS Studio?
I really appreciate your help.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden