(Objective-C) UU Encoding and Decoding
Demonstrates how to UU encode and decode.
#import <CkoCrypt2.h>
#import <NSString.h>
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoCrypt2 *crypt = [[CkoCrypt2 alloc] init];
NSString *s1 = 0;
NSString *s2 = 0;
NSString *s3 = 0;
s1 = @"This string is to be UU encoded";
crypt.UuMode = @"666";
crypt.UuFilename = @"something.txt";
// UU encode:
s2 = [crypt EncodeString: s1 charset: @"ansi" encoding: @"uu"];
// Note: Call crypt.Encode instead of crypt.EncodeString
// to UU encode binary bytes (i.e. non-text binary data).
NSLog(@"%@",s2);
// UU decode:
CkoCrypt2 *crypt2 = [[CkoCrypt2 alloc] init];
s3 = [crypt2 DecodeString: s2 charset: @"ansi" encoding: @"uu"];
// Note: Likewise, call crypt.Decode to decode non-text binary data.
NSLog(@"%@",s3);
// Show the file permissions mode and filename found
// in the UU encoded data:
NSLog(@"%@%@",@"UuMode = ",crypt2.UuMode);
NSLog(@"%@%@",@"UuFilename = ",crypt2.UuFilename);
|