Here you can find the source of utf8urldecode(String text)
public static String utf8urldecode(String text)
//package com.java2s; //License from project: Open Source License import java.nio.charset.StandardCharsets; import java.util.Objects; public class Main { public static String utf8urldecode(String text) { StringBuilder result = new StringBuilder(); int p;//from w w w .j ava2 s .co m if (text != null && text.length() > 0) { text = text.toLowerCase(); p = text.indexOf("%e"); if (p == -1) { return text; } while (p != -1) { result.append(text, 0, p); text = text.substring(p); if (Objects.equals(text, "") || text.length() < 9) { return result.toString(); } result.append(codetoword(text.substring(0, 9))); text = text.substring(9); p = text.indexOf("%e"); } } return result + text; } private static String codetoword(String text) { String result; if (utf8codecheck(text)) { byte[] code = new byte[3]; code[0] = (byte) (Integer.parseInt(text.substring(1, 3), 16) - 256); code[1] = (byte) (Integer.parseInt(text.substring(4, 6), 16) - 256); code[2] = (byte) (Integer.parseInt(text.substring(7, 9), 16) - 256); result = new String(code, StandardCharsets.UTF_8); } else { result = text; } return result; } private static boolean utf8codecheck(String text) { String sign = ""; String prefix = "%e"; if (text.startsWith(prefix)) { for (int p = 0; p != -1;) { p = text.indexOf("%", p); if (p != -1) { p++; } sign += p; } } return "147-1".equals(sign); } }