variation_selector

mautrix.util.variation_selector.add(val)

Add emoji variation selectors (16) 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.

New in version 0.12.5.

Examples

>>> from mautrix.util import variation_selector
>>> variation_selector.add("\U0001f44d")
"\U0001f44d\ufe0f"
>>> variation_selector.add("\U0001f44d\ufe0f")
"\U0001f44d\ufe0f"
>>> variation_selector.add("4\u20e3")
"4\ufe0f\u20e3"
>>> variation_selector.add("\U0001f9d0")
"\U0001f9d0"
Parameters

val (str) – The string to add variation selectors to.

Returns

The string with variation selectors added.

Return type

str

mautrix.util.variation_selector.remove(val)

Remove all emoji variation selectors in the given string.

New in version 0.12.5.

Parameters

val (str) – The string to remove variation selectors from.

Returns

The string with variation selectors removed.

Return type

str

mautrix.util.variation_selector.read_data()

Get the list of emoji that need a variation selector. This loads the local data file that was previously generated from the Unicode spec data files.

Returns

A dict from hex to the emoji string (you have to bring the variation selectors yourself).

Return type

dict[str, str]

async mautrix.util.variation_selector.fetch_data()

Generate the list of emoji that need a variation selector from the Unicode spec data files.

Returns

A dict from hex to the emoji string (you have to bring the variation selectors yourself).

Return type

dict[str, str]