logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

unicode_to_unified_name.js (346B)


  1. function padLeft(str, num) {
  2. while (str.length < num) {
  3. str = '0' + str;
  4. }
  5. return str;
  6. }
  7. exports.unicodeToUnifiedName = (str) => {
  8. let output = '';
  9. for (let i = 0; i < str.length; i += 2) {
  10. if (i > 0) {
  11. output += '-';
  12. }
  13. output += padLeft(str.codePointAt(i).toString(16).toUpperCase(), 4);
  14. }
  15. return output;
  16. };