如何在ColdFusion中创建xml文件时转换utf-8格式的特殊字符

时间:2010-12-17 17:12:15

标签: encoding coldfusion utf-8

我正在使用ColdFusion 5并尝试在创建xml文件时将特殊字符转换为utf-8

我正在使用xmlFormat(),但是当我解析xml文件时,它会给出如下错误:

  

解析xml失败:

     

mountainhomes / xdeadline_listings_wsj.xml:539:解析器错误:输入不正确UTF-8,表示编码!

     

字节:0x96 0x31 0x28 0x32

     5BA,开放式厨房,餐厅和餐厅家庭区域瓦斯燃气日志fp.Lower水平有2个车库

     ÂÂ        

              

1 个答案:

答案 0 :(得分:0)

你可以使用像Demoronize这样的UDF(http://www.cflib.org/index.cfm?event=page.udfbyid&udfid=725)来解决这个问题。我使用dpaste.org(Raw View)查找有问题的字符,获取正确的ascii代码,并将其添加到Demoronize以过滤这些垃圾字符。下面是我添加到原始UDF的列表,用于取出Word引号,elipses等。

text = Replace(text, Chr(96), "'", "All");
text = Replace(text, Chr(198), "'", "All");
text = Replace(text, Chr(8216), "'", "All");
text = Replace(text, Chr(8217), "'", "All");
text = Replace(text, Chr(8220), """", "All");
text = Replace(text, Chr(8221), """", "All");
text = Replace(text, Chr(8230), "...", "All");
text = Replace(text, Chr(244), """", "All");
text = Replace(text, Chr(246), """", "All");
text = Replace(text, Chr(8211), "-", "All");