Here you can find the source of decodeCodedStr(String sourceStr, String targetCharset)
public static String decodeCodedStr(String sourceStr, String targetCharset) throws UnsupportedEncodingException
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; public class Main { public static String decodeCodedStr(String sourceStr, String targetCharset) throws UnsupportedEncodingException { String decodedStr;// w ww . j a v a2 s. co m String changedStr = changeCharset(sourceStr, targetCharset); if (changedStr != null) { try { decodedStr = URLDecoder.decode(URLDecoder.decode(changedStr, targetCharset), targetCharset); } catch (Exception e) { decodedStr = "unknown"; } return decodedStr; } return null; } public static String changeCharset(String str, String targetCharset) throws UnsupportedEncodingException { String targetStr = null; if (str != null) { byte[] byteString = str.getBytes(); targetStr = new String(byteString, targetCharset); } return targetStr; } }