Html.fromHtml() 删除回车符"&#xD"、"\n" [英] Html.fromHtml() removes carriage-returns "&#xD", "\n"

查看:50
本文介绍了Html.fromHtml() 删除回车符"&#xD"、"\n"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为响应,我得到一个字符串,它是 windows .ini 文件,每对都有 &#xD 最后这是规范 XML 中的回车符.

As a response I am getting a string which is windows .ini file each pair has &#xD in the end this is the carriage-return in Canonical XML. After

String ini = Html.fromHtml(response).toString();

ini 获取没有换行符的字符串,而不是空格.如何在它们的位置保持换行?

ini gets string with no line breaks instead of them white-spaces. How to keep line-breaks on their places?

响应为

<字符串xmlns="http://schemas.microsoft.com/2003/10/Serialization/"><?xml version="1.0"encoding="utf-8"?>&lt;Profile>[General]&#xD;AutoRecoveryConversion=1&#xD;UpdateExistingBootScreen=0&#xD;EnableTraditionalBL=1....

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;Profile&gt;[General]&#xD;AutoRecoveryConversion=1&#xD;UpdateExistingBootScreen=0&#xD;EnableTraditionalBL=1....

我必须照原样处理它,服务器不会提供任何更改.

and I have to deal with it as is, no change will be provided from server.

推荐答案

If &amp;#xD; 在响应字符串中替换为 <br/>输出字符串包含正确的换行符.

If &amp;#xD; replaced in response string with <br/> output string contains proper line breaks.

这篇关于Html.fromHtml() 删除回车符&amp;quot;&amp;amp;#xD&amp;quot;、&amp;quot;\n&amp;quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆