gpt4 book ai didi

android - 如何将 unicode\u003c 转换为正确的网页内容并在 android webview 中显示正确的内容所以我应该怎么做

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:20:56 24 4
gpt4 key购买 nike

我从服务器收到了以下 json 文件。它是 unicode 字符,我想转换成正确的网页内容,然后想在网页 View 中显示正确的内容请任何人帮助我!

content":"\u003Cstrong\u003EHas there ever been a more open looking Epsom
Derby?\u003C\/strong\u003E\r\n\u003Cp\u003EThe fact that two
fillies - both
unlikely to run for obvious reasons - are highly prominent in the
betting market tells it's own story.\u003C\/p\u003E\r\n\u003Cp\u003ESo
far at least this
has not exactly been a vintage year for the classic colts division.\u003C\/p\u003E\r\n\u003Cp\u003EAir
Force Blue never kicked
into gear
at all in the 2,000 Guineas while the Derby market has been in constant
turmoil.\u003C\/p\u003E\r\n\u003Cp\u003EUS Army Ranger going
to the top of the betting for winning a glorified slow bicycle
race on horrible ground at The Curragh was only the start of the fun."

最佳答案

试试这个

String result = removeUTFCharacters(unicodeString).toString();

public static StringBuffer removeUTFCharacters(String data){
Pattern p = Pattern.compile("\\\\u(\\p{XDigit}{4})");
Matcher m = p.matcher(data);
StringBuffer buf = new StringBuffer(data.length());
while (m.find()) {
String ch = String.valueOf((char) Integer.parseInt(m.group(1), 16));
m.appendReplacement(buf, Matcher.quoteReplacement(ch));
}
m.appendTail(buf);
return buf;
}

结果将是:

<strong>Has there ever been a more open looking Epsom
Derby?<\/strong>\r\n<p>The fact that two
fillies - both
unlikely to run for obvious reasons - are highly prominent in the
betting market tells it's own story.<\/p>\r\n<p>So
far at least this
has not exactly been a vintage year for the classic colts division.<\/p>\r\n<p>Air
Force Blue never kicked
into gear
at all in the 2,000 Guineas while the Derby market has been in constant
turmoil.<\/p>\r\n<p>US Army Ranger going
to the top of the betting for winning a glorified slow bicycle
race on horrible ground at The Curragh was only the start of the fun.

关于android - 如何将 unicode\u003c 转换为正确的网页内容并在 android webview 中显示正确的内容所以我应该怎么做,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37293783/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com