【发布时间】:2012-10-21 08:26:29
【问题描述】:
当我从 twitter 的 Stream API 读取数据然后写入 xmlfile 时。
但是像�这样的特殊字符会导致错误(我的意思是当我在Chrome中打开那个xml文件时,Chrome说那个字符有错误!)
我想在写入 xmlfile 之前将该编码序列 (�) 转换为真实字符 ()!
如何实现?
-------------已添加--------------
这是 XMLFile 的内容:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<text>@carlyraejepsen would be a dream if you follow me, please follow me?, I love you so much you're my inspiration</text>
<text>someone please bring me a caramel apple and a mocha from black cat. i'll love you forever</text>
<text>“@G_MartinFlyKick: Marry me Juliet.I love you and that's all I really know.”����������</text>
<text>"I need to see a picture of him cuz Im trying to imagine you guys making love and all I see is u climbing on top of a big question mark"lmao</text>
<text>@District3music hi, I LOVE YOU follow me please? &lt;3 xx 23</text>
<text>RT @syardley_: So appreciative of my family and people I love, wouldn't be where I am without them. #thankful</text>
<text>#DISTRICT3HALLOWEENFOLLOWSPREE #DISTRICT3HALLOWEENFOLLOWSPREE #3EEKERFROMTHENETHERLANDS love you! Please follow ? @District3music x42</text>
<text>Arguably my favorite electronic music producer @Kluteuk is coming back to Toronto on Dec 22nd. So stoked. Guy has made so many tunes I LOVE.</text>
<text>The stakes are high, the water's rough, but this love is ours.</text>
<text>@NiallOfficial Answer me, I love you very much. Venezuela loves. jhgj</text>
<text>Love this shit http://t.co/qSP79NKx</text>
</root>
这是来自 Chrome 的错误:
This page contains the following errors:
error on line 5 at column 91: xmlParseCharRef: invalid xmlChar value 55357
Below is a rendering of the page up to the first error.
【问题讨论】:
-
您使用什么语言/框架? 。网? C? 6502汇编器?
-
错误说明了什么?请向我们展示 XML。
-
我添加了更多细节@SLaks