I'm looking to take a string containing html character entities such as
etc and replace them with the literal string characters. I'm getting data via twitter's api and the text contains those entities. Anyone know of an existing library which does this?
Thanks for your help!
Hello try the code below it will work out
The Web.Encodings package on hackage looks promising (the decodeHtml function):
http://hackage.haskell.org/packages/archive/web-encodings/0.3.0.2/doc/html/Web-Encodings.html
I built the following function with functions from the package
tagsoup
. It handles all named and numeric entities from the HTML5 Standard (more than 2000, see the list).StringLike
has instances forString
, Lazy and StrictByteString
andText
.Unknown entites will be left intact. If you want a warning about unknown entities use: