Unescape字符串不起作用,它只删除“逃避”

时间:2018-04-13 14:56:07

标签: java utf-8

public ArvinYML replaceOldKey() {
    for(String key : toFile().getKeys()) {
        if(toFile().get(key) != null && !key.startsWith("#") && !key.startsWith(Main.get().getDescription().getName() + "_CMT_")) {
            if(toFile().getConfigurationSection(key) != null) {
                loopKey(key);
            } else {
                String value = "";
                value = StringEscapeUtils.unescapeXml(String.valueOf(config.get(key)));
                data.put(key, value);
            }
        }
    }
}

那是我的代码,我试过unescapejava和xml,它只删除转义而不编码utf8

结果:

Before

After

有人可以帮我找到我的代码有什么问题吗?

1 个答案:

答案 0 :(得分:1)

根据docs unescapeXML

  

仅支持五个基本XML实体(gt,lt,quot,amp,apos)。   不支持DTD或外部实体。

您可能想要使用unescapeXML11

  

escapeXml11将转义以下范围内的字符:   [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] | [#x86的#x9F]   ...

相关问题