Reorder Unicode emojis

Reorder Unicode emojis according to Unicode CLDR emoji collation rules.
This commit is contained in:
yan 2023-02-01 18:09:17 +02:00
parent b4b13d777f
commit d5b078e084
3 changed files with 5709 additions and 1435 deletions

View File

@ -159,13 +159,13 @@ const instance = {
const res = await window.fetch('/static/emoji.json')
if (res.ok) {
const values = await res.json()
const emoji = Object.keys(values).map((key) => {
const emoji = values.map((key) => {
return {
displayText: key,
displayText: key.keyword,
imageUrl: false,
replacement: values[key]
replacement: key.value
}
}).sort((a, b) => a.name > b.name ? 1 : -1)
})
commit('setInstanceOption', { name: 'emoji', value: emoji })
} else {
throw (res)

File diff suppressed because it is too large Load Diff

27
tools/sort_emojis.js Normal file
View File

@ -0,0 +1,27 @@
const fs = require('fs')
const emojiFilename = '../static/emoji.json'
const data = fs.readFileSync(emojiFilename, 'utf8')
const currentEmojis = JSON.parse(data)
const currentEmojisArray = Object.entries(currentEmojis).map(([name, codepoint]) => {
return {
keyword: name,
value: codepoint
}
}).filter(e => {
const hasSingleCodepoint = Array.from(e.value).length === 1;
const isSkinToneIndicator = e.value.codePointAt(0) >= 0x1F3FB && e.value.codePointAt(0) <= 0x1F3FF;
return !(hasSingleCodepoint && isSkinToneIndicator)
})
const collator = new Intl.Collator('en-u-co-emoji')
currentEmojisArray.sort((a, b) => {
return collator.compare(a.value, b.value)
})
fs.writeFile(emojiFilename, JSON.stringify(currentEmojisArray, null, 2), 'utf8', (err) => {
if (err) console.log('Error writing file', err)
})