html - 如何在 Elixir 中对字符串进行 html 解码?

标签 html string elixir decode

这是我要解码的字符串。

"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_entities来自 Hex.pm 的包

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"

关于html - 如何在 Elixir 中对字符串进行 html 解码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38866786/

相关文章:

html - IE7 - 显示 : block <a> within <li> does not display correctly

javascript - 计算点击总和并追加总计?

C++:带有空格的cin到没有getline函数的字符串

elixir - 如何检查 eex 中是否存在变量?

elixir - 如何为 has_one/belongs_to_many 关联定义 Elixir Ecto 模式?

Elixir:(FunctionClauseError)没有函数子句匹配

css - 垂直对齐 float 图像旁边的多条线

javascript - 降低图像分辨率/尺寸以显示为预览

java - 如何将1的补码转换成2的补码?

php - 如何在 PHP 中删除部分字符串?