Java 将 Unicode 字符串转换为英文字符串

Java Convert Unicode String to English String

我是 java 的新手,我有这样的角色

"%6D%61%61%20%77%61%72%64%20%6C%6F%20%65%6E%6E%69%20%73%61%72%6C%75%20%68%6F%75%73%65%20%73%69%74%65%20%6B%6F%72%61%6B%75%20%61%70%70%6C%79%20%63%68%65%73%69%6E%61%20%6D%61%27%61%6D%20%65%74%75%76%61%6E%74%69%20%75%70%61%79%6F%67%61%6D%20%6C%65%6B%75%6E%64%61%20%69%6E%64%69%76%69%64%75%61%6C%20%70%6F%79%69%6E%64%69%20%74%72%79%20%63%68%65%79%61%6D%61%6E%74%61%72%61%61%20%76%61%64%69%6C%65%79%61%6D%61%6E%74%61%61%72%61%20%70%6C%65%61%73%65%20%73%65%6E%64%20%6D%65%20%61%6E%73%77%65%72"

当我尝试使用此 tool 转换它们时。我可以根据需要转换为值。

转换结果:

"maa ward lo enni sarlu house site koraku apply chesina ma'am etuvanti upayogam lekunda individual poyindi try cheyamantaraa vadileyamantaara please send me answer"

但是我如何以编程方式使用有人可以提供帮助吗?

我试过了

String raw = "%6D%61%61%20%77%61%72%64%20%6C%6F%20%65%6E%6E%69%20%73%61%72%6C%75%20%68%6F%75%73%65%20%73%69%74%65%20%6B%6F%72%61%6B%75%20%61%70%70%6C%79%20%63%68%65%73%69%6E%61%20%6D%61%27%61%6D%20%65%74%75%76%61%6E%74%69%20%75%70%61%79%6F%67%61%6D%20%6C%65%6B%75%6E%64%61%20%69%6E%64%69%76%69%64%75%61%6C%20%70%6F%79%69%6E%64%69%20%74%72%79%20%63%68%65%79%61%6D%61%6E%74%61%72%61%61%20%76%61%64%69%6C%65%79%61%6D%61%6E%74%61%61%72%61%20%70%6C%65%61%73%65%20%73%65%6E%64%20%6D%65%20%61%6E%73%77%65%72";
String searchSection = new String(raw.getBytes(StandardCharsets.UTF_8), "UTF-8");
System.out.println( searchSection);

如果这个问题与任何其他问题重复,请指出正确的方向谢谢

转换后的文本应该匹配

您可以使用 java.net 中的 URLDecoder.decode(yourMessage, "UTF-8") 实现它:

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class Main {
    public static void main(String[] args) {
        String yourMessage = "%6D%61%61%20%77%61%72%64%20%6C%6F%20%65%6E%6E%69%20%73%61%72%6C%75%20%68%6F%75%73%65%20%73%69%74%65%20%6B%6F%72%61%6B%75%20%61%70%70%6C%79%20%63%68%65%73%69%6E%61%20%6D%61%27%61%6D%20%65%74%75%76%61%6E%74%69%20%75%70%61%79%6F%67%61%6D%20%6C%65%6B%75%6E%64%61%20%69%6E%64%69%76%69%64%75%61%6C%20%70%6F%79%69%6E%64%69%20%74%72%79%20%63%68%65%79%61%6D%61%6E%74%61%72%61%61%20%76%61%64%69%6C%65%79%61%6D%61%6E%74%61%61%72%61%20%70%6C%65%61%73%65%20%73%65%6E%64%20%6D%65%20%61%6E%73%77%65%72";

        try {
            System.out.println( URLDecoder.decode(yourMessage, "UTF-8"));
        } catch (UnsupportedEncodingException uee) { }

    }
}

输出:

maa ward lo enni sarlu house site koraku apply chesina ma'am etuvanti upayogam lekunda individual poyindi try cheyamantaraa vadileyamantaara please send me answer