Xfce Cstring/GString Functions: libxfce4util Reference Manual

## Xfce Cstring/GString Functions Xfce Cstring/GString Functions — various functions to handle string |

## Functions

void | xfce_g_string_append_quoted ()
gchar * | xfce_str_replace ()
#define | xfce_str_is_empty()
#define | I_()

## Includes

    #include <libxfce4util/libxfce4util.h>

## Description

## Functions

### xfce_g_string_append_quoted ()

    void
    xfce_g_string_append_quoted (GString *string,
                                 const gchar *unquoted);

Quotes a string `unquoted` and appends to an existing GString `string` . The shell will interpret the quoted string to mean `unquoted` . The quoting style used is undefined (check `g_shell_quote()`).

#### Parameters

string | A GString. |
unquoted | A literal string. |

Since: 4.17

### xfce_str_replace ()

    gchar *
    xfce_str_replace (const gchar *str,
                      const gchar *pattern,
                      const gchar *replacement);

Searches `str` for occurances of `pattern` and replaces each such occurance with `replacement` . Returns a newly allocated copy of `str` on which the given replacement were performed. The caller is responsible to free the returned string using `g_free()` when no longer needed.

Note that `pattern` and `replacement` don't need to be of the same size. If `replacement` is `NULL`, the pattern will be removed from the string.

Note for future Xfce developers: Deprecate this function when `g_string_replace()` is available. (Added since Glib >= 2.68)

#### Parameters

str | the input string. |
pattern | a search pattern in `str` . |
replacement | replacement string for `pattern` . |

#### Returns

a newly allocated copy of `str` where all occurrences of `pattern` are replaced with `replacement` . Or `NULL` if `str` is `NULL`.

[nullable][transfer full]

Since: 4.17

### xfce_str_is_empty()

    #define xfce_str_is_empty(string) ((string) == NULL || *(string) == '\0')

Macro to check if a string is `NULL` or empty. You should prefer this function over strlen (str) == 0.

#### Parameters

string | a string |

#### Returns

`TRUE` if the string is `NULL` or empty, `FALSE` otherwise.

Since : 4.17

### I_()

    #define I_(string) (g_intern_static_string ((string)))

Shortcut for `g_intern_static_string()` to return a canonical representation for `string` .

#### Parameters

string | A static string. |

#### Returns

a canonical representation for the string.

Since : 4.17