1

There are some sentences in my database ( Arabic ) has decimal uni codes for quotations mark and some other elements like it.

an example of a text I have:

"كريم نجار: تداعيات “كورونا” ستغير مستقبل سوق السيارات العالمية وقد تشهد السوق المحلية إرتفاعاً في الأسعار"

I searched on how to decode something like this in NodeJS but I didn't find anything useful, for example, I have tried the unescape package but didn't work for me.

hesham shawky
  • 1,073
  • 4
  • 21
  • 44
  • Here you can find your perfect solution visit https://stackoverflow.com/questions/147824/how-to-find-whether-a-particular-string-has-unicode-characters-esp-double-byte – Rajnish singh Jun 14 '20 at 03:58
  • 2
    It's not what I need, I need to convert this from what it's above to text. the above links just a check if the string contains a Unicode or not which is not my case here! – hesham shawky Jun 14 '20 at 20:27

1 Answers1

0

A possible simple solution is to push your string into an HTML text area and read the output back. This will not work in Node.

<script>
function decodeEntity(inStr) {
    var textarea = document.createElement("textarea");
    textarea.innerHTML = inStr;
    return textarea.value;
}

let str = "كريم نجار: تداعيات &#8220;كورونا&#8221; ستغير مستقبل سوق السيارات العالمية وقد تشهد السوق المحلية إرتفاعاً في الأسعار"

console.log(decodeEntity(str));
</script>
Mohsen Alyafei
  • 4,765
  • 3
  • 30
  • 42