public static String toGBK(String source) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); byte[] bytes = source.getBytes("GBK"); for (byte b : bytes) { sb.append("%" + Integer.toHexString((b & 0xff)).toUpperCase()); } return sb.toString(); }