Java ISO to GB String iso2Gb(String gbString)

Here you can find the source of iso2Gb(String gbString)

Description

Converts string from GB2312 encoding ISO8859-1 (Latin-1) encoding.

License

Open Source License

Parameter

Parameter Description
gbString The string of GB1212 encoding

Return

New string of ISO8859-1 encoding

Declaration

public static String iso2Gb(String gbString) 

Method Source Code

//package com.java2s;

public class Main {
    /**//  ww w  .  j  a va2 s  .co  m
     * Converts string from GB2312 encoding ISO8859-1 (Latin-1) encoding.
     * 
     * @param gbString
     *            The string of GB1212 encoding
     * @return New string of ISO8859-1 encoding
     */
    public static String iso2Gb(String gbString) {
        if (gbString == null)
            return null;
        String outString = "";
        try {
            byte[] temp = null;
            temp = gbString.getBytes("ISO8859-1");
            outString = new String(temp, "GB2312");
        } catch (java.io.UnsupportedEncodingException e) {
            // ignore it as no way to convert between these two encodings
        }
        return outString;
    }
}

Related

  1. ISO2GB(String text)