Function

GLibutf8_substring

since: 2.30

Declaration [src]

gchar*
g_utf8_substring (
  const gchar* str,
  glong start_pos,
  glong end_pos
)

Description [src]

Copies a substring out of a UTF-8 encoded string. The substring will contain end_pos - start_pos characters.

Since GLib 2.72, -1 can be passed to end_pos to indicate the end of the string.

Available since: 2.30

Parameters

str

Type: const gchar*

A UTF-8 encoded string.

The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
start_pos

Type: glong

A character offset within str.

end_pos

Type: glong

Another character offset within str, or -1 to indicate the end of the string.

Return value

Type: gchar*

A newly allocated copy of the requested substring. Free with g_free() 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.