Function

GLibutf8_pointer_to_offset

Declaration

glong
g_utf8_pointer_to_offset (
  const gchar* str,
  const gchar* pos
)

Description

Converts from a pointer to position within a string to an integer character offset.

Since 2.10, this function allows pos to be before str, and returns a negative offset in this case.

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.
pos

Type: const gchar*

A pointer to a position within str.

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

Return value

Type: glong

The resulting character offset.