2023-05-09 11:08:47 +10:00
|
|
|
/* eslint-disable import/no-commonjs --
|
|
|
|
We need to use CommonJS here as its imported into a preval file (`emoji_compressed.js`) */
|
|
|
|
|
2017-10-06 12:42:34 +11:00
|
|
|
function padLeft(str, num) {
|
|
|
|
while (str.length < num) {
|
|
|
|
str = '0' + str;
|
|
|
|
}
|
2021-06-01 22:35:49 +10:00
|
|
|
|
2017-10-06 12:42:34 +11:00
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.unicodeToUnifiedName = (str) => {
|
|
|
|
let output = '';
|
2021-06-01 22:35:49 +10:00
|
|
|
|
2017-10-06 12:42:34 +11:00
|
|
|
for (let i = 0; i < str.length; i += 2) {
|
|
|
|
if (i > 0) {
|
|
|
|
output += '-';
|
|
|
|
}
|
2021-06-01 22:35:49 +10:00
|
|
|
|
2017-10-06 12:42:34 +11:00
|
|
|
output += padLeft(str.codePointAt(i).toString(16).toUpperCase(), 4);
|
|
|
|
}
|
2021-06-01 22:35:49 +10:00
|
|
|
|
2017-10-06 12:42:34 +11:00
|
|
|
return output;
|
|
|
|
};
|