2

我在 Haskell 中编写了一个小型 RSS 提要下载器,但我遇到了这个故事的问题。RSS 项目是:

<item>
    <title>Defense lawyer says gov’t hid NSA role in California terrorism case</title>
    <link>http://feeds.arstechnica.com/~r/arstechnica/index/~3/hh41K3S-dug/</link>
    <comments>http://arstechnica.com/tech-policy/2013/06/defense-lawyer-says-govt-hid-nsa-role-in-california-terrorism-case/#comments</comments>
    <pubDate>Wed, 19 Jun 2013 17:04:16 +0000</pubDate>
    <dc:creator>Cyrus Farivar</dc:creator>
    <category><![CDATA[Law & Disorder]]></category>
    <category><![CDATA[FISA]]></category>
    <category><![CDATA[FISC]]></category>
    <category><![CDATA[NSA]]></category>
    <category><![CDATA[san diego]]></category>
    <category><![CDATA[Terrorism]]></category>

    <guid isPermaLink="false">http://arstechnica.com/?p=292287</guid>
    <description><![CDATA["We're going to evaluate our options as to what to do now," attorney says.]]></description>
    <content:encoded><![CDATA[<div id="rss-wrap"> <p>Now that the <a href="http://arstechnica.com/tech-policy/2013/06/nsa-head-says-digital-spying-has-disrupted-a-little-over-10-plots-domestically/">National Security Agency (NSA) and other law enforcement institutions have begun to pull </a><a style="font-size: 14px; line-height: 19px;" href="http://arstechnica.com/tech-policy/2013/06/nsa-head-says-digital-spying-has-disrupted-a-little-over-10-plots-domestically/">back </a><a style="font-size: 14px; line-height: 19px;" href="http://arstechnica.com/tech-policy/2013/06/nsa-head-says-digital-spying-has-disrupted-a-little-over-10-plots-domestically/">the veil on surveillance tactics</a><span style="font-size: 14px; line-height: 19px;"> and their newly disclosed relationship in suspected terrorism cases, at least one defense attorney is starting to challenge previously closed cases.</span></p>
            <p>Among the cases officials cited where NSA surveillance proved useful in securing a conviction was that of <a href="https://www.fbi.gov/sandiego/press-releases/2013/san-diego-jury-convicts-four-somali-immigrants-of-providing-support-to-foreign-terrorists">Basaaly Saeed Moalin</a>, a San Diego cab driver. Moalin was convicted in February 2013 on five counts, including conspiracy to provide material support to a foreign terrorist organization, Somali terrorist group Al Shabaab.</p>
            <p>"We're going to evaluate our options as to what to do now to get to the bottom of this," Joshua Dratel, a New York-based defense attorney representing Moalin, told <em><a href="http://www.wired.com/threatlevel/2013/06/nsa-defense-lawyers/">Wired</a></em> on Tuesday. "We can't learn about it until it's to the government's tactical advantage politically to disclose it. National security is about keeping illegal conduct concealed from the American public until you're forced to justify it because someone ratted you out."</p>
            </div><p><a href="http://arstechnica.com/tech-policy/2013/06/defense-lawyer-says-govt-hid-nsa-role-in-california-terrorism-case/#p3">Read 5 remaining paragraphs</a> | <a href="http://arstechnica.com/tech-policy/2013/06/defense-lawyer-says-govt-hid-nsa-role-in-california-terrorism-case/?comments=1">Comments</a></p><div class="feedflare">
            <a href="http://feeds.arstechnica.com/~ff/arstechnica/index?a=hh41K3S-dug:QhYtCojMxzM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/arstechnica/index?i=hh41K3S-dug:QhYtCojMxzM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.arstechnica.com/~ff/arstechnica/index?a=hh41K3S-dug:QhYtCojMxzM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/arstechnica/index?i=hh41K3S-dug:QhYtCojMxzM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.arstechnica.com/~ff/arstechnica/index?a=hh41K3S-dug:QhYtCojMxzM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/arstechnica/index?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.arstechnica.com/~ff/arstechnica/index?a=hh41K3S-dug:QhYtCojMxzM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/arstechnica/index?d=yIl2AUoC8zA" border="0"></img></a>
    </div><img src="http://feeds.feedburner.com/~r/arstechnica/index/~4/hh41K3S-dug" height="1" width="1"/>]]></content:encoded>
    <wfw:commentRss>http://arstechnica.com/tech-policy/2013/06/defense-lawyer-says-govt-hid-nsa-role-in-california-terrorism-case/feed/</wfw:commentRss>
    <slash:comments>0</slash:comments>
    <feedburner:origLink>http://arstechnica.com/tech-policy/2013/06/defense-lawyer-says-govt-hid-nsa-role-in-california-terrorism-case/</feedburner:origLink>
</item>

Haskell 似乎不喜欢标题中使用的撇号。

  1. 我的第一次尝试遇到了无效字符错误
  2. 在 stdout 上明确设置 UTF-8 后,它变得更好了。
  3. 如果我将它保存到本地文件(复制粘贴到 Vim 中),我得到的结果略有不同

然而,这些都不会导致撇号被正确解释和打印。我应该注意我正在使用 Text.XML.Light 进行解析,如果我写出文件而不是打印到控制台,结果似乎是相同的。

知道为什么这不起作用吗?作为参考,我的代码在这里

4

1 回答 1

2

HTTP 包似乎没有正确解码字节。是一个使用 Data.Text 的decodeUtf8手动进行解码的版本,它可以正常工作。我不确定是否有更好的方法。

于 2013-06-19T20:11:16.983 回答