编码特殊字符 [英] Encoding Special Characters
本文介绍了编码特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种方法来将基本ASCII字符集(1-127)中的所有字符更改为等效的扩展代码。代码表示为&#[code];
例如,度数符号将变为°
有没有办法在序列化或编码过程中执行此操作?
谢谢!< br> Brian
解决方案
您可以实现自己的XmlWriter(可以通过扩展现有的XmlWriter实现来完成),也可以使用XSLT和样式表复制除了将编码更改为US-ASCII之外的所有内容:
< xsl:stylesheet version = " 1.0" xmlns: xsl = " http://www.w3.org/1999/XSL/Transform" > < xsl:output method = " xml" < font style ="color:red"> encoding = " US-ASCII" /> < xsl:template match = " @ * | node()" > < xsl:copy > < xsl:apply-templates 选择 = " @ * | node()" /> < / xsl:copy > < / xsl:template > < / xsl:stylesheet >
I'm looking for a way to change all characters not in the basic ASCII character set (1-127) to their equivalent extended code. The codes are represented as &#[code];
For example, a degree symbol would become °
Is there a way to do this as part of a serialization or encoding process?
Thanks!
Brian解决方案You can either implement your own XmlWriter (can be done by extending an existing XmlWriter implementation) that does that or you can use XSLT and a stylesheet copying everything but changing the encoding to US-ASCII:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="US-ASCII"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
这篇关于编码特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文