This feels like one of those operations that must be common enough that this is a duplicate question, but since I was not able to find it anywhere:
What is the most straightforward way to replace HTML entities with their string representations in a Go string
? That is, how would I turn the string Rø&d grød & fløde
into Rød grød & fløde
?
My own solutions have been either using strings.Replace
on all relevant entities (which quickly becomes intractable), or wrapping the string into an XML document and decoding it with xml.Decoder
(which seems silly and leads to numerous edge cases).