Function

GLibUriescape_bytes

since: 2.66

Declaration [src]

char*
g_uri_escape_bytes (
  const guint8* unescaped,
  gsize length,
  const char* reserved_chars_allowed
)

Description [src]

Escapes arbitrary data for use in a URI.

Normally all characters that are not ‘unreserved’ (i.e. ASCII alphanumerical characters plus dash, dot, underscore and tilde) are escaped. But if you specify characters in reserved_chars_allowed they are not escaped. This is useful for the ‘reserved’ characters in the URI specification, since those are allowed unescaped in some portions of a URI.

Though technically incorrect, this will also allow escaping nul bytes as %``00.

Available since: 2.66

Parameters

unescaped

Type: An array of guint8

The unescaped input data.

The length of the array is specified in the length argument.
The data is owned by the caller of the function.
length

Type: gsize

The length of unescaped.

reserved_chars_allowed

Type: const char*

A string of reserved characters that are allowed to be used, or NULL.

The argument can be NULL.
The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.

Return value

Type: char*

An escaped version of unescaped. The returned string should be freed when no longer needed.

The caller of the function takes ownership of the data, and is responsible for freeing it.
The value is a NUL terminated UTF-8 string.