Chilkat HOME Android™ ASP Visual Basic VB.NET C# iOS (IPhone) Objective-C C++ C Unicode C++ Unicode C MFC Delphi DLL Delphi ActiveX FoxPro Java Perl PHP Extension PHP ActiveX Python PowerShell Ruby SQL Server VBScript
|
Quoted-Printable Encode/Decode a StringObjective-C example to quoted-printable encode and decode a string. Download: Chilkat Cocoa Objective-C Libraries NSMutableString *strOutput = [NSMutableString stringWithCapacity:1000]; CkoCrypt2 *crypt = [[[CkoCrypt2 alloc] init] autorelease]; // Any string argument automatically begins the 30-day trial. BOOL success; success = [crypt UnlockComponent: @"30-day trial"]; if (success != YES) { [strOutput appendString: crypt.LastErrorText]; [strOutput appendString: @"\n"]; self.mainTextField.stringValue = strOutput; return; } // Here's a string in Icelandic using non us-ascii chars: NSString *s; s = @"Ég get etið gler án þess að meiða mig."; crypt.CryptAlgorithm = @"none"; crypt.EncodingMode = @"quoted-printable"; // Quoted-printable encode/decode the iso-8859-1 // representation of the string. Notice how each // Icelandic char is represented by 1 byte: crypt.Charset = @"iso-8859-1"; NSString *qp; qp = [crypt EncryptStringENC: s]; [strOutput appendString: @"iso-8859-1:"]; [strOutput appendString: @"\n"]; [strOutput appendString: qp]; [strOutput appendString: @"\n"]; NSString *decoded; decoded = [crypt DecryptStringENC: qp]; [strOutput appendString: decoded]; [strOutput appendString: @"\n"]; // Now do the same using utf-8. Notice how each // Icelandic char is represented by 2 bytes in utf-8: crypt.Charset = @"utf-8"; qp = [crypt EncryptStringENC: s]; [strOutput appendString: @"utf-8:"]; [strOutput appendString: @"\n"]; [strOutput appendString: qp]; [strOutput appendString: @"\n"]; decoded = [crypt DecryptStringENC: qp]; [strOutput appendString: decoded]; [strOutput appendString: @"\n"]; self.mainTextField.stringValue = strOutput; |
© 2000-2013 Chilkat Software, Inc. All Rights Reserved.