I have a variable that contains html characters. This variable must be converted to an html safe string. How do I do this? Example:
data.X="<img src='abc'>";
//data.X=magicEncoder(data.X)
//Contents of data.X after magicEncoder:
<img src='abc'>
I have tried looking up domPurify without success only to have it strip the html instead of encoding the contents.