【问题标题】:How to html decode a string in Elixir?如何在 Elixir 中对字符串进行 html 解码?
【发布时间】:2016-12-16 10:43:36
【问题描述】:

这是我要解码的字符串。

"Ren & Stimpy The Lost Episodes Disc.1 [MP4-AAC] 480p DVD"

我想以如下字符串结尾:

"Ren & Stimpy The Lost Episodes Disc.1 [MP4-AAC] 480p DVD"

我尝试使用 URI.decode 函数,但它不起作用,我得到相同的 & 符号。

iex(1)> URI.decode "Ren & Stimpy The Lost Episodes Disc.1 [MP4-AAC] 480p DVD"
"Ren & Stimpy The Lost Episodes Disc.1 [MP4-AAC] 480p DVD"

【问题讨论】:

标签: html string elixir decode


【解决方案1】:

从 Hex.pm 添加 html_entities

defp deps do
  [{:html_entities, "~> 0.5.2"}]
end

然后将你的字符串传递给它:

iex> HtmlEntities.decode("Ren & Stimpy The Lost Episodes Disc.1 [MP4-AAC] 480p DVD")
"Ren & Stimpy The Lost Episodes Disc.1 [MP4-AAC] 480p DVD"

【讨论】:

    猜你喜欢
    • 2021-08-23
    • 2019-08-18
    • 1970-01-01
    • 1970-01-01
    • 2014-12-10
    • 2012-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多