[英]How to convert characters beyond ASCII range to HTML entities
Currently I'm running the replace like this: 目前我正在运行这样的替换:
.replace("®", "®")
.replace("°", "°")
.replace("™", "™")
.replace("©", "©")
But that relies on a lot to go right before I get to this point. 但在我达到这一点之前,这依赖于很多事情。 What's a better way to do this? 有什么更好的方法呢?
You can use this utils class: http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringEscapeUtils.html 您可以使用此utils类: http : //commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringEscapeUtils.html
In your particular case it will be StringEscapeUtils.escapeHtml(...)
在您的特定情况下,它将是StringEscapeUtils.escapeHtml(...)
http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml(java.lang.String ) http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml(java.lang.String )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.