bigbuffet-rw/app/soapbox/features/emoji/unicode_to_unified_name.js

22 lines
350 B
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
function padLeft(str, num) {
while (str.length < num) {
str = '0' + str;
}
2021-07-09 21:57:54 -07:00
2020-03-27 13:59:38 -07:00
return str;
}
exports.unicodeToUnifiedName = (str) => {
let output = '';
2021-07-09 21:57:54 -07:00
2020-03-27 13:59:38 -07:00
for (let i = 0; i < str.length; i += 2) {
if (i > 0) {
output += '-';
}
2021-07-09 21:57:54 -07:00
2020-03-27 13:59:38 -07:00
output += padLeft(str.codePointAt(i).toString(16).toUpperCase(), 4);
}
2021-07-09 21:57:54 -07:00
2020-03-27 13:59:38 -07:00
return output;
};