community.general.unicode_normalize filter – Normalizes unicode strings to facilitate comparison of characters with normalized forms

Note

This filter plugin is part of the community.general collection (version 10.1.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.unicode_normalize.

New in community.general 3.7.0

Synopsis

  • Normalizes unicode strings to facilitate comparison of characters with normalized forms.

Input

This describes the input of the filter, the value before | community.general.unicode_normalize.

Parameter

Comments

Input

string / required

A unicode string.

Positional parameters

This describes positional parameters of the filter. These are the values positional1, positional2 and so on in the following example: input | community.general.unicode_normalize(positional1, positional2, ...)

Parameter

Comments

form

string

The normal form to use.

See https://docs.python.org/3/library/unicodedata.html#unicodedata.normalize for details.

Choices:

  • "NFC" ← (default)

  • "NFD"

  • "NFKC"

  • "NFKD"

Examples

- name: Normalize unicode string
  ansible.builtin.set_fact:
    dictionary: "{{ 'ä' | community.general.unicode_normalize('NFKD') }}"
    # The resulting string has length 2: one letter is 'a', the other
    # the diacritic combiner.

Return Value

Key

Description

Return value

string

The normalized unicode string of the specified normal form.

Returned: success

Authors

  • Andrew Pantuso (@Ajpantuso)

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.