Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Shift_JIS to iso-2022-jp ConversionConvert Shift_JIS to iso-2022-jp
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[]) { CkCharset charset = new CkCharset(); // Any string argument automatically begins the 30-day trial. boolean success; success = charset.UnlockComponent("30-day trial"); if (success != true) { System.out.println("Charset component unlock failed"); return; } // Set the "To" and "From" charsets: charset.put_FromCharset("shift_JIS"); charset.put_ToCharset("iso-2022-jp"); // To do file-to-file conversion, call ConvertFile. // The shift_JIS sample file is downloadable from this URL: // http://www.chilkatsoft.com/testData/japanese_shiftJis.txt success = charset.ConvertFile("japanese_shiftJis.txt","japanese_iso2022jp.txt"); if (success != true) { System.out.println(charset.lastErrorText()); } else { System.out.println("Success"); } // To do memory-to-memory conversion, load the text data // into a CkByteData, then convert: CkByteData srcTxt = new CkByteData(); success = srcTxt.loadFile("japanese_shiftJis.txt"); if (success != true) { System.out.println("Failed to load source Shift_JIS text file"); return; } CkByteData destTxt = new CkByteData(); // Convert Shift_JIS to Japanese JIS (iso-2022-jp) success = charset.ConvertData(srcTxt,destTxt); if (success != true) { System.out.println(charset.lastErrorText()); return; } success = destTxt.saveFile("out.txt"); if (success != true) { System.out.println("Failed to save output file"); return; } // Access the iso-2022-jp bytes like this: byte[] txtData; txtData = destTxt.toByteArray(); } } |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.