How to html decode a string in Elixir?

Here is the line I'm trying to decode.

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

I would like to get a string, for example:

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

I tried using URI.decode , but it does not work, I get the same character &.

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"
+4
source share
1 answer

Add html_entities package with Hex.pm

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

Then just pass it your line:

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"
+6
source

Source: https://habr.com/ru/post/1650772/


All Articles