### Function

# GLib utf8_pointer_to_offset

since: 2.0

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

Available since: 2.0

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