## as-utils as-utils — Helper functions that are used inside libappstream |

## Functions

gchar * | as_markup_convert_simple ()
gboolean | as_utils_locale_is_compatible ()
gboolean | as_utils_is_category_name ()
gboolean | as_utils_is_tld ()
gboolean | as_utils_is_desktop_environment ()
void | as_utils_sort_components_into_categories ()
gint | as_utils_compare_versions ()
const gchar * | as_get_appstream_version ()

## Includes

    #include <appstream.h>

## Description

Functions which are used in libappstream and might be useful for others as well.

## Functions

### as_markup_convert_simple ()

    gchar *
    as_markup_convert_simple (const gchar *markup,
                              GError **error);

### as_utils_locale_is_compatible ()

    gboolean
    as_utils_locale_is_compatible (const gchar *locale1,
                                   const gchar *locale2);

Calculates if one locale is compatible with another. When doing the calculation the locale and language code is taken into account if possible.

#### Parameters

locale1 | a locale string, or `NULL` |
locale2 | a locale string, or `NULL` |

#### Returns

`TRUE` if the locale is compatible.

Since: 0.9.5

### as_utils_is_category_name ()

    gboolean
    as_utils_is_category_name (const gchar *category_name);

### as_utils_is_tld ()

    gboolean
    as_utils_is_tld (const gchar *tld);

Searches the known list of TLDs we allow for AppStream IDs. This excludes internationalized names.

#### Parameters

tld | a top-level domain without dot, e.g. "de", "org", "name" |

#### Returns

`TRUE` if the TLD is valid

Since: 0.9.8

### as_utils_is_desktop_environment ()

    gboolean
    as_utils_is_desktop_environment (const gchar *desktop);

Searches the known list of desktop environments AppStream knows about.

#### Parameters

desktop | a desktop environment id. |

#### Returns

`TRUE` if the desktop-id is valid

Since: 0.10.0

### as_utils_sort_components_into_categories ()

    void
    as_utils_sort_components_into_categories
                                   (GPtrArray *cpts,
                                    GPtrArray *categories,
                                    gboolean check_duplicates);

Sorts all components in `cpts` into the AsCategory categories listed in `categories` .

#### Parameters

cpts | List of components. | [element-type AsComponent]
categories | List of categories to sort components into. | [element-type AsCategory]
check_duplicates | Whether to check for duplicates. |

### as_utils_compare_versions ()

    gint
    as_utils_compare_versions (const gchar *a,
                               const gchar *b);

Compare alpha and numeric segments of two versions. The version compare algorithm is also used by RPM.

#### Returns

1: a is newer than b 0: a and b are the same version -1: b is newer than a

### as_get_appstream_version ()

    const gchar *
    as_get_appstream_version (void);

Get the version of the AppStream library that is currently used as a string.

#### Returns

The AppStream version.

## Types and Values