Convert String in gb To Utf - Java Internationalization

Java examples for Internationalization:Chinese

Description

Convert String in gb To Utf

Demo Code


import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import javax.servlet.http.HttpServletResponse;

public class Main{
    public static String gbToUtf8(String src) {
        byte[] b = src.getBytes();
        char[] c = new char[b.length];
        for (int i = 0; i < b.length; i++) {
            c[i] = (char) (b[i] & 0x00FF);
        }//  w w w.j av  a  2 s. c om
        return new String(c);
    }
}

Related Tutorials