0

i have a following problem: I am parsing a website with Node-Red "html request"-component. It returns a UTF-8 String representation of a web page, which i try to process afterwards in Javascript function. My problem ist that strings in some elements on the page are being encoded like

привет

which should actualy say

привет

What kind of escaping is that? It looks like unicode, but with "&#x" instead of "/u0". How can i make the text human-readable again using javascript?

user48538
  • 3
  • 2

1 Answers1

0

Maybe like this:

var str='привет';

var div = document.createElement('div');
div.innerHTML = str;
var new_str=div.firstChild.nodeValue;
console.log(new_str);
mscdeveloper
  • 2,749
  • 1
  • 10
  • 17
  • Thank you all for your help! I want to describe my solution here. As Node-Red uses server-side javascript and misses all the browser-site javascript features like DOM-Parser i have used this solution https://stackoverflow.com/questions/18749591/encode-html-entities-in-javascript – user48538 Jul 13 '18 at 10:02