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

发布于 2024-10-08 07:22:46 字数 376 浏览 0 评论 0原文

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

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

解析 xml 失败:

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

字节:0x96 0x31 0x28 0x32

5BA,开放式厨房,餐厅和厨房带燃气日志的家庭区。下层有 2 个车库

、 、 、 、 、 、 、 、 、 、 、 、 、 、 、 、 、 、 、 、 、 ^

I am using ColdFusion 5 and trying to convert special characters to utf-8 while creating xml file

I am using xmlFormat() for that, But when I parsing the xml file it is giving error like this:

Parsing xml failed:

mountainhomes/xdeadline_listings_wsj.xml:539: parser error : Input is not proper UTF-8, indicate encoding !

Bytes: 0x96 0x31 0x28 0x32

5BA,open kitchen,dining & family area w/gas log fp.Lower level has 2 garages

                                                                     Â&n bsp;        ^

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-10-15 07:22:46

您可以使用 Demoronize (http://www.cflib.org/index.cfm?event=page.udfbyid&udfid=725) 等 UDF 来解决此问题。我使用 dpaste.org(原始视图)来查找有问题的字符,获取正确的 ascii 代码,并将其添加到 Demoronize 以过滤这些垃圾字符。下面是我添加到原始 UDF 中的列表,用于删除 Word 引号、省略号等。

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");

You can use a UDF like Demoronize (http://www.cflib.org/index.cfm?event=page.udfbyid&udfid=725) to solve this. I use dpaste.org (Raw View) to find the offending character, get the proper ascii code, and add it to Demoronize to filter these garbage characters. Below are a list that I've added to the original UDF to take out Word quotes, elipses, etc.

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");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文