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

 

 

 

 

 

 

 

Utf-8 Source File Encoding for Java

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

Explains how to use utf-8 encoding for your Java source files so you may use string literals in any language.

Download Java Programming Examples

// When you compile this program with the command javac Utf8Test.java, 
// the compiler does not know the encoding of the source file. Therefore it uses your
// computer's default encoding. You should tell javac which encoding to 
// use explicitly. Use the -encoding option to do this: 
// javac -encoding utf8 Utf8Test.java .
	
// Also, do not emit the 3-byte BOM (byte order mark) signature at the 
// beginning of the file.  The BOM bytes will cause  javac compiler to fail.
// Files containing the 3-byte utf-8 BOM will begin with 0xEF 0xBB 0xBF
	
import com.chilkatsoft.CkString;

public class Utf8Test {
	
  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[]) 
  {
  	// Because this source code is saved using the utf-8 character
  	// encoding, we can write literal strings in any language.
  	// This is a Japanese string:
  	String test = "愛知県新城市の";
  	
  	// Chilkat provides a CkString class that is used with 
  	// many of the other Chilkat classes.
    CkString str = new CkString();
    // Java strings may be appended.
    str.append(test);
    
    // Save the string in various encodings.    
    str.saveToFile("utf8.txt","utf-8");
    str.saveToFile("shiftJis.txt","shift_JIS");
    str.saveToFile("iso-2022-jp.txt","iso-2022-jp");
    str.saveToFile("euc-jp.txt","euc-jp");
    
  }
}

 

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.