GLib.utf8_get_char_validated
Description: Reference for GLib.utf8_get_char_validated

### Function

# GLibutf8_get_char_validated

#### Declaration [src]

    gunichar
    g_utf8_get_char_validated (
      const gchar* p,
      gssize max_len
    )

#### Description [src]

Convert a sequence of bytes encoded as UTF-8 to a Unicode character.

This function checks for incomplete characters, for invalid characters such as characters that are out of the range of Unicode, and for overlong encodings of valid characters.

Note that `g_utf8_get_char_validated()` returns `(gunichar)-2` if `max_len` is positive and any of the bytes in the first UTF-8 character sequence are nul.

#### Parameters

`p`

  Type: `const gchar*`

  A pointer to Unicode character encoded as UTF-8.

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

`max_len`

  Type: `gssize`

  The maximum number of bytes to read, or `-1` if `p` is nul-terminated.

#### Return value

Type: `gunichar`

The resulting character. If `p` points to a partial sequence at the end of a string that could begin a valid character (or if `max_len` is zero), returns `(gunichar)-2`; otherwise, if `p` does not point to a valid UTF-8 encoded Unicode character, returns `(gunichar)-1`.