Java Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

Java Examples

Quick Start
Unicode
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
SFTP
Signatures
SMTP
Socket / SSL
Spider
SSH
SSH Key
SSH Tunnel
Tar
Upload
XML
XMP
Zip

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

 

Shift_JIS to iso-2022-jp Conversion

Convert Shift_JIS to iso-2022-jp

 Chilkat Java Library Downloads for Windows, Linux, and MAC OS X

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.