Skip to content

Instantly share code, notes, and snippets.

@Caellian
Last active January 19, 2024 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Caellian/947e9b7b0f9d42278b9308765dc4ec08 to your computer and use it in GitHub Desktop.
Save Caellian/947e9b7b0f9d42278b9308765dc4ec08 to your computer and use it in GitHub Desktop.
Emoji list update
#!/bin/env sh
function check_version() {
curl -s "https://unicode.org/Public/cldr/$1/" | grep -o "core.zip<" >/dev/null && echo 0 || echo 1
}
function cldr_versions() {
curl -s "https://unicode.org/Public/cldr/" | grep -oP "(?<=<li><a href=\")\d+(\.\d+)*" | tac
}
echo "Downloading version list..."
for v in $(cldr_versions); do
echo "Checking version $v..."
if [[ $(check_version $v) -eq 0 ]]; then
echo "Downloading CLDR v$v..."
curl "https://unicode.org/Public/cldr/$v/core.zip" -o "cldr-core.zip"
break
fi
done
echo "Extracting zip contents..."
unzip "cldr-core.zip" common/annotations/en.xml -d .
echo "Formatting sequences..."
cat common/annotations/en.xml |
grep -shP "annotation cp=\".\">" |
sed -Ee "s/\s+<annotation cp=\"//g; s/\">/ /g; s|</annotation>||g; s/\s\|\s/, /g" > emoji_list
echo "Cleaning up CLDR files..."
rm -rf common cldr-core.zip
echo "Done."
@BeyondMagic
Copy link

Please, update the script, it's unable to download now the .zips :|

@Caellian
Copy link
Author

Fixed. Regex for extracting versions from version directory was broken.

@karimb
Copy link

karimb commented Oct 29, 2023

I'm afraid cldr_versions() no longer returns anything. Would you mind updating it please?

@Caellian
Copy link
Author

Caellian commented Oct 30, 2023

@karimb Updated. They changed version list to use list element instead of a table.

@karimb
Copy link

karimb commented Oct 30, 2023

@Caellian Thanks 🙂 I think you should have a donation link somewhere. Even small donations are encouraging 😉

@Caellian
Copy link
Author

@karimb Np, thanks for letting me know.
I don't feel like donations for this script would be justifiable given that I left it as a comment on Luke's video and it took very little effort to write it and keep it updated (3 minor revisions in 3 years).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment