这是我要解码的字符串。
"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/