Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix #1

Merged
merged 1 commit into from
Jul 19, 2021
Merged

bugfix #1

merged 1 commit into from
Jul 19, 2021

Conversation

zhangzhiqiang37
Copy link

首先表示作者这个仓库的代码设计的很不错,且也解决了我实际的问题,用于分割字符和计算字符的长度

然后鉴于在我使用的时候,发现一些存在的问题点,我这边 fork 了一个仓库,请求 pr,将代码合进来,也作出一份自己的贡献

以下是对修改点的逐个说明:

1、10-11行,参考 unicode emoji 13.1 的文档附录C http://unicode.org/reports/tr51/#valid-emoji-tag-sequences 以及 emoji_tag_sequence 说明 http://unicode.org/reports/tr51/#def_emoji_tag_sequence ,我将此处修改了。emoji_tag_sequence 的 tag_spec 是有明确的范围并且限制长度的,不过这些都不算太重要,重要的是懒匹配是一定要加上的,当多个表情连在一起的时候会出现前后表情及其中间的内容全都连在一起识别为一个表情了的问题,例子 🏴🏴‍☠️🏴󠁧󠁢󠁥󠁮󠁧󠁿🏴󠁧󠁢󠁳󠁣󠁴󠁿🏴󠁧󠁢󠁷󠁬󠁳󠁿 他们在一起出现就认为只有一个表情也只有一个字符
2、20-21行,参考 unicode emoji 13.1 的文档 text presentation selector 的说明 http://unicode.org/reports/tr51/#def_text_presentation_selector \ufe0e 可以修饰一个表情使用文本的形式去呈现,合并起来也是一个单位,所以这里 EMOJI_INDICATORS 加上 \ufe0e,例子 \u270f\ufe0f 是 emoji 表情的铅笔,\u270f\ufe0e 是文本形式的铅笔
3、46-54行,参考 unicode emoji 13.1 的文档 color 的说明 http://unicode.org/reports/tr51/#color ZWJ 可直接拼接 \u2b1b 和 \u2b1c ,例子就是那只黑色的猫
4、66-69行,有一些基本表情是靠 \ufe0f 来修饰出来的表情,他们也可以使用肤色修饰,修饰的时候又可以不带 \ufe0f,就导致有直接 \uxxxx\ud83c\udffb 这种case,所以这里 _matchForwarding 支持直接在 /\ud83c[\udffb-\udfff]/ 前面加一个符号的模式,例子 ☝️☝🏻 分别是 \u261d\ufe0f 和 \u261d\ud83c\udffb
5、101行,这个很好理解,匹配成功了一条规则就应该退出该 for 循环了,不应该再用另一个规则去匹配,不然会有连着的表情前者命中第一条规则后者命中后面的规则,就会被认为是一个表情(一个字符),例子 🇨🇳😀 ,先命中 pairs of regional indicators 规则,再命中 range of surrogate pairs 规则
6、255行,建议开放一个 matchOneEmoji 接口,给其他人使用,进行一些更丰富的功能的开发

🤝🤝🤝

@ayqy
Copy link
Owner

ayqy commented Jul 19, 2021

Nice work! 看得出来是很用心的commit 👍

@ayqy ayqy merged commit 8dbe3d0 into ayqy:master Jul 19, 2021
@ayqy
Copy link
Owner

ayqy commented Jul 19, 2021

1.0.0 带上了本PR 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants