String to Chinese Encoding - Java Internationalization

Java examples for Internationalization:Charset

Description

String to Chinese Encoding

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String ss = "java2s.com";
        System.out.println(toChinese(ss));
    }/*  w w  w  .  j  a v a 2s . c  o  m*/

    public static String toChinese(String ss) {
        if (ss != null) {
            try {
                String tmpe = ss;
                byte[] temp_t = tmpe.getBytes("ISO8859-1");
                ss = new String(temp_t, "gb2312");

            } catch (Exception e) {
                e.printStackTrace();
            }

        }
        return ss;
    }
}

Related Tutorials