gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-31 08:07:04 25 4
gpt4 key购买 nike

这是我要解码的字符串。

"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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com