Java tutorial
//package com.java2s; public class Main { public static String encodeStr(String str, String srcEncoding, String destEncoding) { String ret = null; try { ret = new String(str.getBytes(srcEncoding), destEncoding); } catch (Exception e) { ret = srcEncoding + " to " + destEncoding + " error. str=" + str; } return (ret); } }