Unescape HTML entities in Javascript?

前端 未结 30 2935
野趣味
野趣味 2020-11-21 05:40

I have some Javascript code that communicates with an XML-RPC backend. The XML-RPC returns strings of the form:


30条回答
  •  野的像风
    2020-11-21 06:07

    To unescape HTML entities* in JavaScript you can use small library html-escaper: npm install html-escaper

    import {unescape} from 'html-escaper';
    
    unescape('escaped string');
    

    Or unescape function from Lodash or Underscore, if you are using it.


    *) please note that these functions don't cover all HTML entities, but only the most common ones, i.e. &, <, >, ', ". To unescape all HTML entities you can use he library.

提交回复
热议问题