variationselector

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package variationselector provides utility functions for adding and removing emoji variation selectors (16) that matches the suggestions in the Matrix spec.

Index

Examples

Constants

View Source
const VS16 = "\ufe0f"

Variables

This section is empty.

Functions

func Add

func Add(val string) string

Add adds emoji variation selectors to all emojis that have multiple forms in the given string.

This will remove all variation selectors first to make sure it doesn't add duplicates.

Example
package main

import (
	"fmt"
	"strconv"

	"maunium.net/go/mautrix/util/variationselector"
)

func main() {
	fmt.Println(strconv.QuoteToASCII(variationselector.Add("\U0001f44d")))           // thumbs up (needs selector)
	fmt.Println(strconv.QuoteToASCII(variationselector.Add("\U0001f44d\ufe0f")))     // thumbs up with variation selector (stays as-is)
	fmt.Println(strconv.QuoteToASCII(variationselector.Add("\U0001f44d\U0001F3FD"))) // thumbs up with skin tone (shouldn't get selector)
	fmt.Println(strconv.QuoteToASCII(variationselector.Add("\U0001f914")))           // thinking face (shouldn't get selector)
}
Output:

"\U0001f44d\ufe0f"
"\U0001f44d\ufe0f"
"\U0001f44d\U0001f3fd"
"\U0001f914"

func Remove

func Remove(val string) string

Remove removes all emoji variation selectors in the given string.

Example
package main

import (
	"fmt"
	"strconv"

	"maunium.net/go/mautrix/util/variationselector"
)

func main() {
	fmt.Println(strconv.QuoteToASCII(variationselector.Remove("\U0001f44d")))
	fmt.Println(strconv.QuoteToASCII(variationselector.Remove("\U0001f44d\ufe0f")))
}
Output:

"\U0001f44d"
"\U0001f44d"

Types

This section is empty.

Jump to

Keyboard shortcuts

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