Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Re-Encode a String (Hex, Base64, URL, etc)Demonstrates how to convert from one encoding to another. For example: base64 to hex, URL to base64, base64 to quoted-printable, etc. Note: The ReEncode method is unreleased at the time of this writing (08-April-2008) The next major Chilkat Crypt2 release after this date will include the ReEncode method. import com.chilkatsoft.*; public class ChilkatExample { static { try { System.loadLibrary("chilkat"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load.\n" + e); System.exit(1); } } public static void main(String argv[]) { CkCrypt2 crypt = new CkCrypt2(); // Any string argument automatically begins the 30-day trial. boolean success; success = crypt.UnlockComponent("30-day trial"); if (success != true) { System.out.println("Crypt component unlock failed"); return; } String hexStr; hexStr = "41424344E0E1E2E3"; String fromEncoding; fromEncoding = "hex"; String toEncoding; toEncoding = "base64"; // Convert from hex to base64 String base64; base64 = crypt.reEncode(hexStr,fromEncoding,toEncoding); System.out.println(base64); // Now convert from base64 to quoted-printable: fromEncoding = "base64"; toEncoding = "quoted-printable"; String qp; qp = crypt.reEncode(base64,fromEncoding,toEncoding); System.out.println(qp); // Now convert from quoted-printable to URL: fromEncoding = "quoted-printable"; toEncoding = "url"; String urlEnc; urlEnc = crypt.reEncode(qp,fromEncoding,toEncoding); System.out.println(urlEnc); // Now convert from URL back to hex: fromEncoding = "url"; toEncoding = "hex"; hexStr = crypt.reEncode(urlEnc,fromEncoding,toEncoding); System.out.println(hexStr); // The output of this program is: // QUJDRODh4uM= // ABCD=E0=E1=E2=E3 // ABCD%E0%E1%E2%E3 // 41424344E0E1E2E3 } } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.