0

Here's an example string, I want to decode the special characters :

"<div class="c1-snippet">
    Let&rsquo;s see if you can run Troubleshooter. Select the &lt;strong&gt;Start&lt;/strong&gt; button, 
    select &lt;strong&gt;Settings&lt;/strong&gt; &gt; &lt;strong&gt;Update &amp;amp; security&lt;/strong&gt; 
 </div>"

I tried renderHTML from 'react-render-html', either use it once or twice, it's only render unescaped parts.

Troubleshooter. 
Select the <strong>Start</strong> button, 
select <strong>Settings</strong> > 
<strong>Update &amp; security</strong> > <strong>Activation</strong>
2
  • 1
    Possible duplicate of Unescape HTML entities in Javascript? Commented Aug 21, 2018 at 18:26
  • yep, I solved the problem by htmlDecode in js-htmlencode Commented Aug 21, 2018 at 21:47

1 Answer 1

1

Install the following package: https://www.npmjs.com/package/html-escape-unescape

Import it in the module.

Use like this:

{{ someStringToBeEscaped | escape }}
{{ someStringToBeUnescaped | unescape }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.