Skip to content

Instantly share code, notes, and snippets.

@dmjcomdem
Last active June 30, 2018 09:45
Show Gist options
  • Save dmjcomdem/e3bfbecf9d9ac4702d337853d47a66ba to your computer and use it in GitHub Desktop.
Save dmjcomdem/e3bfbecf9d9ac4702d337853d47a66ba to your computer and use it in GitHub Desktop.
Перевод html сущности в utf-8
let decodeHtmlEntity = (str) => {
return str.replace(/&#?x(.+?);/gi, (match, dec) => String.fromCharCode('0x' + dec));
};
// decodeHtmlEntity('БУ ХМАО-Югры МИАЦ')
// "БУ ХМАО-Югры МИАЦ"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment