Emoji: Update to Unicode 13.1, switch base file, allow multichar.

This commit is contained in:
lain 2020-12-02 16:15:03 +01:00
parent 5a5ff508aa
commit 1adee08321
3 changed files with 4889 additions and 11 deletions

4879
lib/pleroma/emoji-test.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -102,7 +102,7 @@ defp update_emojis(emojis) do
:ets.insert(@ets, emojis) :ets.insert(@ets, emojis)
end end
@external_resource "lib/pleroma/emoji-data.txt" @external_resource "lib/pleroma/emoji-test.txt"
emojis = emojis =
@external_resource @external_resource
@ -114,17 +114,12 @@ defp update_emojis(emojis) do
|> String.split(";", parts: 2) |> String.split(";", parts: 2)
|> hd() |> hd()
|> String.trim() |> String.trim()
|> String.split("..") |> String.split()
|> case do |> Enum.map(fn codepoint ->
[number] -> <<String.to_integer(codepoint, 16)::utf8>>
<<String.to_integer(number, 16)::utf8>> end)
|> Enum.join()
[first, last] ->
String.to_integer(first, 16)..String.to_integer(last, 16)
|> Enum.map(&<<&1::utf8>>)
end
end) end)
|> List.flatten()
|> Enum.uniq() |> Enum.uniq()
for emoji <- emojis do for emoji <- emojis do

View File

@ -9,8 +9,12 @@ defmodule Pleroma.EmojiTest do
describe "is_unicode_emoji?/1" do describe "is_unicode_emoji?/1" do
test "tells if a string is an unicode emoji" do test "tells if a string is an unicode emoji" do
refute Emoji.is_unicode_emoji?("X") refute Emoji.is_unicode_emoji?("X")
refute Emoji.is_unicode_emoji?("")
assert Emoji.is_unicode_emoji?("") assert Emoji.is_unicode_emoji?("")
assert Emoji.is_unicode_emoji?("🥺") assert Emoji.is_unicode_emoji?("🥺")
assert Emoji.is_unicode_emoji?("🤰")
assert Emoji.is_unicode_emoji?("❤️")
end end
end end