Giter VIP home page Giter VIP logo

go.emoji's Introduction

Build codecov Go Report Card codebeat badge

GoDoc EmojiVer License

This Package emoji is designed to recognize and parse every individual Unicode Emoji characters from a string.

Example

func main() {
	s := "👩‍👩‍👦🇨🇳"
	i := 0

	final := emoji.ReplaceAllEmojiFunc(s, func(emoji string) string {
		i++
		fmt.Printf("%02d - %s - UTF-8 len %d\n", i, emoji, len(emoji))
		return fmt.Sprintf("%d-", i)
	})

	fmt.Printf("final: <%s>\n", final)
}

// Output:
// 01 - 👩‍👩‍👦 - UTF-8 len 18
// 02 - 🇨🇳 - UTF-8 len 8
// final: <1-2->

go.emoji's People

Contributors

andrew-m-c avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go.emoji's Issues

你的go.emoji/official/emoji-sequences.go有问题吧?范围标识变成只有2个??

打比方unicode文档内的标识是:
1F191..1F19A ; Basic_Emoji ; CL button # E0.6 [10] (🆑..🆚)

而你生成出来的只有2个,实际上源文档内这里有10个符号:
AllSequences.AddSequence([]rune{0x1f191}, "Basic_Emoji ==> 🆑")
AllSequences.AddSequence([]rune{0x1f191, 0xfe0e}, "Basic_Emoji ==> 🆑")
AllSequences.AddSequence([]rune{0x1f19a}, "Basic_Emoji ==> 🆚")
AllSequences.AddSequence([]rune{0x1f19a, 0xfe0e}, "Basic_Emoji ==> 🆚")

有很多符号都匹配不了,比如 🎵 这个

[兼容性问题] 旧版本红心无法被识别

问题表现:

红心表情有两个,❤️[表情符号]和❤[文字符号]
文字符号版本在当前库版本下无非被正确识别替换。

研究进展

其原因我有研究是因为红心在 emoji 诞生前就存在于 unicode 编码中,老的编码短的那个

0x2764 ❤

老的在新版本还有个编码

0x2764 0xFE0E ❤

新版本的编码是这样:

0x2764 0xFE0F ❤️

我还找到了 unicode 编码官网,它的emoji-sequences.txt同样只有新的编码,在旧版本中存在0x2764老编码。
https://www.unicode.org/Public/emoji/15.1/emoji-sequences.txt

但我没研究明白,如何让这个库兼容旧的红心❤识别。

附上对这个问题的讨论

https://stackoverflow.com/questions/42679712/why-does-the-red-heart-emoji-require-two-code-points-but-the-other-colored-hear

还有对两个两种红心编码的文字定义介绍:

https://www.emojiall.com/zh-hans/code/2764

期待这个库能够提供兼容的方案

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.