Here you can find the source of toGB2312(String s)
Parameter | Description |
---|---|
s | The Target string |
public static String toGB2312(String s) throws Exception
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w .ja va2 s. c o m*/ * Encode the string to GB2312 * * @param s * The Target string * @return The string after encode. */ public static String toGB2312(String s) throws Exception { if (s != null && s.length() > 0) { byte[] byteTmp = s.getBytes("ISO8859_1"); s = new String(byteTmp, "GB2312"); } return s; } }