Skip to content

mahongran/go.emoji

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDoc

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

Example

replace emoji

func main() {
	printf := fmt.Printf

	s := "👩‍👩‍👦🇨🇳"
	i := 0

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

	printf("final: <%s>\n", final)
}

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

check emoji

emoji.HasEmoji("👩‍👩‍👦")

// Output:
// true

filter emoji

emoji.FilterEmoji("1⃣️23")

// Output:
// 23

human read length

emoji.HumanReadLen("👩‍👩‍👦23")

// Output:
// 3

dump emoji

emoji.Dump("👨‍👩‍👧‍👦")
string:👨‍👩‍👧‍👦,byte count25, character count7
======================
seq 0Unicode codeU+1f468byte count4
seq 1Unicode codeU+200dbyte count3
seq 2Unicode codeU+1f469byte count4
seq 3Unicode codeU+200dbyte count3
seq 4Unicode codeU+1f467byte count4
seq 5Unicode codeU+200dbyte count3
seq 6Unicode codeU+1f466byte count4

About

Golang emoji parser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%