Skip to content

Commit d1d7313

Browse files
committed
[*] chore: Update official reference
1 parent b5f3ec4 commit d1d7313

4 files changed

Lines changed: 31 additions & 80 deletions

File tree

‎internal/official/emoji-sequences.go‎

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/official/emoji-sequences.txt‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# emoji-sequences.txt
2-
# Date: 2025-04-23, 17:41:13 GMT
2+
# Date: 2025-07-25, 17:54:32 GMT
33
# © 2025 Unicode®, Inc.
44
# Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
55
# For terms of use and license, see https://www.unicode.org/terms_of_use.html
@@ -325,7 +325,6 @@
325325
1FAD7..1FAD9 ; Basic_Emoji ; pouring liquid..jar # E14.0 [3] (🫗..🫙)
326326
1FADA..1FADB ; Basic_Emoji ; ginger root..pea pod # E15.0 [2] (🫚..🫛)
327327
1FADC ; Basic_Emoji ; root vegetable # E16.0 [1] (🫜)
328-
1FADD ; Basic_Emoji ; apple core # E17.0 [1] (🫝)
329328
1FADF ; Basic_Emoji ; splatter # E16.0 [1] (🫟)
330329
1FAE0..1FAE7 ; Basic_Emoji ; melting face..bubbles # E14.0 [8] (🫠..🫧)
331330
1FAE8 ; Basic_Emoji ; shaking face # E15.0 [1] (🫨)
@@ -542,7 +541,7 @@
542541
1F6F0 FE0F ; Basic_Emoji ; satellite # E0.7 [1] (🛰️)
543542
1F6F3 FE0F ; Basic_Emoji ; passenger ship # E0.7 [1] (🛳️)
544543

545-
# Total elements: 1401
544+
# Total elements: 1400
546545

547546
# ================================================
548547

‎internal/tool/const/download.go‎

Lines changed: 7 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,22 @@ import (
66
"io"
77
"net/http"
88
"os"
9-
"regexp"
10-
"strconv"
11-
"strings"
129
)
1310

1411
func downloadEmoji() {
1512
// list and find latest emoji versions
16-
s, err := httpGet(emojiOfficialURL)
17-
var lines []string
18-
check(err)
19-
20-
if find := strings.SplitN(s, "Parent Directory", 2); len(find) == 1 {
21-
printf("error, cannot find emoji sub directories")
22-
os.Exit(-1)
23-
} else {
24-
lines = strings.Split(find[1], "\n")
25-
}
26-
27-
latest := ""
28-
rep := regexp.MustCompile(`(\d+\.\d+)\/.+20\d\d-[01]\d-\d\d`)
29-
for _, line := range lines {
30-
match := rep.FindStringSubmatch(line)
31-
if len(match) < 2 {
32-
continue
33-
}
34-
35-
v := match[1]
36-
printf("found version: %s", v)
37-
38-
if vercmp(latest, v) < 0 {
39-
latest = v
40-
}
41-
}
13+
latest := emojiLatestVersion
4214

4315
// check old emoji-data file
44-
data, err := httpGet(emojiOfficialURL + emojiOldDataFileVer + "/" + emojiOfficialDataFile)
16+
data, err := httpGet(emojiDataFileURL())
4517
check(err)
4618

4719
printf("latest version: %v", latest)
4820

4921
// get emoji and zwj files
50-
basic, err := httpGet(emojiOfficialURL + latest + "/" + emojiOfficialSeqFile)
22+
basic, err := httpGet(emojiSeqFileURL(latest))
5123
check(err)
52-
zwj, err := httpGet(emojiOfficialURL + latest + "/" + emojiOfficialZwjSeqFile)
24+
zwj, err := httpGet(emojiZwjSeqFileURL(latest))
5325
check(err)
5426

5527
err = os.WriteFile(emojiDataFile, []byte(data), 0644)
@@ -59,45 +31,12 @@ func downloadEmoji() {
5931
err = os.WriteFile(emojiZwjSeqFile, []byte(zwj), 0644)
6032
check(err)
6133

62-
referenceURL = emojiOfficialURL + latest + "/"
63-
}
64-
65-
func vercmp(left, right string) int {
66-
if left == "" {
67-
if right == "" {
68-
return 0
69-
}
70-
return -1
71-
}
72-
if right == "" {
73-
return 1
74-
}
75-
76-
toCode := func(s string) uint32 {
77-
nums := strings.Split(s, ".")
78-
if len(nums) == 1 {
79-
n, _ := strconv.ParseUint(s, 10, 32)
80-
return uint32(n) << 16
81-
}
82-
83-
hi, _ := strconv.ParseUint(nums[0], 10, 32)
84-
lo, _ := strconv.ParseUint(nums[1], 10, 32)
85-
return (uint32(hi) << 16) + uint32(lo)
86-
}
87-
88-
leftCode := toCode(left)
89-
rightCode := toCode(right)
90-
91-
if leftCode < rightCode {
92-
return -1
93-
}
94-
if leftCode > rightCode {
95-
return 1
96-
}
97-
return 0
34+
referenceURL = dataFile(latest, "")
9835
}
9936

10037
func httpGet(u string) (res string, err error) {
38+
printf("request: %s", u)
39+
10140
resp, err := http.Get(u)
10241
if err != nil {
10342
return "", fmt.Errorf("http.Get(%s) error: %w", u, err)

‎internal/tool/const/main.go‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,42 @@ import (
1616
// https://www.jianshu.com/p/9682f8ce1260
1717

1818
const (
19-
emojiOfficialURL = "https://www.unicode.org/Public/emoji/"
20-
2119
emojiOldDataFileVer = "12.1"
2220

23-
emojiOfficialDataFile = "emoji-data.txt"
24-
emojiOfficialSeqFile = "emoji-sequences.txt"
25-
emojiOfficialZwjSeqFile = "emoji-zwj-sequences.txt"
26-
2721
emojiDataFile = "../../../internal/official/emoji-data.txt"
2822
emojiSeqFile = "../../../internal/official/emoji-sequences.txt"
2923
emojiZwjSeqFile = "../../../internal/official/emoji-zwj-sequences.txt"
3024

3125
emojiDataGoFile = "../../../internal/official/emoji-sequences.go"
3226

27+
emojiLatestVersion = "17.0.0"
28+
3329
// typeEmojiBasic = " Basic_Emoji "
3430
// typeEmojiKeycapSequence = " Emoji_Keycap_Sequence "
3531
// typeEmojiFlagSequence = " RGI_Emoji_Flag_Sequence "
3632
// typeEmojiTagSequence = " RGI_Emoji_Tag_Sequence "
3733
// typeEmojiModifierSequence = " RGI_Emoji_Modifier_Sequence "
3834
)
3935

36+
func dataFile(version, filename string) string {
37+
return fmt.Sprintf(
38+
"https://www.unicode.org/Public/%s/emoji/%s",
39+
version, filename,
40+
)
41+
}
42+
43+
func emojiDataFileURL() string {
44+
return fmt.Sprintf("https://www.unicode.org/Public/emoji/%s/emoji-data.txt", emojiOldDataFileVer)
45+
}
46+
47+
func emojiSeqFileURL(version string) string {
48+
return dataFile(version, "emoji-sequences.txt")
49+
}
50+
51+
func emojiZwjSeqFileURL(version string) string {
52+
return dataFile(version, "emoji-zwj-sequences.txt")
53+
}
54+
4055
var (
4156
referenceURL = ""
4257
longestRunes [][]rune

0 commit comments

Comments
 (0)