emoji

package module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: BSD-3-Clause, MIT Imports: 2 Imported by: 7 modules, 9 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README ΒΆ

go.emoji

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->

Documentation ΒΆ

Overview ΒΆ

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

Unicode Emoji Documents: https://www.unicode.org/Public/emoji/

Index ΒΆ

Examples ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func ReplaceAllEmojiFunc ΒΆ

func ReplaceAllEmojiFunc(s string, f func(emoji string) string) string

ReplaceAllEmojiFunc searches string and find all emojis.

Example ΒΆ
package main

import (
	"fmt"

	emoji "github.com/Andrew-M-C/go.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->

Types ΒΆ

type CharIterator ΒΆ added in v1.1.0

type CharIterator interface {
	Current() string
	CurrentIsEmoji() bool
	Next() bool
}

CharIterator is used in RangeChars

func IterateChars ΒΆ added in v1.1.0

func IterateChars(s string) CharIterator

IterateChars iterates a string, and extract every characters.

Example ΒΆ
package main

import (
	"fmt"

	emoji "github.com/Andrew-M-C/go.emoji"
)

func main() {
	s := "China:πŸ‡¨πŸ‡³;Japan:πŸ‡―πŸ‡΅"

	for it := emoji.IterateChars(s); it.Next(); {
		fmt.Println(it.Current(), "-", it.CurrentIsEmoji())
	}

}
Output:
C - false
h - false
i - false
n - false
a - false
: - false
πŸ‡¨πŸ‡³ - true
; - false
J - false
a - false
p - false
a - false
n - false
: - false
πŸ‡―πŸ‡΅ - true

Directories ΒΆ

Path Synopsis
internal
official
Package official indicates official unicode emoji variables.
Package official indicates official unicode emoji variables.
tool/const command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 捒网址