### Function

# GLib Uri split

since: 2.66

#### Declaration [src]

    gboolean
    g_uri_split (
      const gchar* uri_ref,
      GUriFlags flags,
      gchar** scheme,
      gchar** userinfo,
      gchar** host,
      gint* port,
      gchar** path,
      gchar** query,
      gchar** fragment,
      GError** error
    )

#### Description [src]

Parses `uri_ref` (which can be an absolute or relative URI) according to `flags`, and returns the pieces. Any component that doesn’t appear in `uri_ref` will be returned as `NULL` (but note that all URIs always have a path component, though it may be the empty string).

If `flags` contains `G_URI_FLAGS_ENCODED`, then `%`-encoded characters in `uri_ref` will remain encoded in the output strings. (If not, then all such characters will be decoded.) Note that decoding will only work if the URI components are ASCII or UTF-8, so you will need to use `G_URI_FLAGS_ENCODED` if they are not.

Note that the `G_URI_FLAGS_HAS_PASSWORD` and `G_URI_FLAGS_HAS_AUTH_PARAMS` `flags` are ignored by g_uri_split(), since it always returns only the full userinfo; use `g_uri_split_with_user()` if you want it split up.

Available since: 2.66

#### Parameters

`uri_ref`

  Type: `const gchar*`

  A string containing a relative or absolute URI.

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

`flags`

  Type: `GUriFlags`

  Flags for parsing `uri_ref`.

`scheme`

  Type: `gchar**`

  On return, contains the scheme (converted to lowercase), or `NULL`.

  The argument will be set by the function.
  The argument can be set to `NULL` by the function.
  The argument can be `NULL`.
  The caller of the function takes ownership of the returned data, and is responsible for freeing it.
  The value is a NUL terminated UTF-8 string.

`userinfo`

  Type: `gchar**`

  On return, contains the userinfo, or `NULL`.

  The argument will be set by the function.
  The argument can be set to `NULL` by the function.
  The argument can be `NULL`.
  The caller of the function takes ownership of the returned data, and is responsible for freeing it.
  The value is a NUL terminated UTF-8 string.

`host`

  Type: `gchar**`

  On return, contains the host, or `NULL`.

  The argument will be set by the function.
  The argument can be set to `NULL` by the function.
  The argument can be `NULL`.
  The caller of the function takes ownership of the returned data, and is responsible for freeing it.
  The value is a NUL terminated UTF-8 string.

`port`

  Type: `gint*`

  On return, contains the port, or `-1`.

  The argument will be set by the function.
  The argument can be `NULL`.

`path`

  Type: `gchar**`

  On return, contains the path.

  The argument will be set by the function.
  The argument can be `NULL`.
  The caller of the function takes ownership of the returned data, and is responsible for freeing it.
  The value is a NUL terminated UTF-8 string.

`query`

  Type: `gchar**`

  On return, contains the query, or `NULL`.

  The argument will be set by the function.
  The argument can be set to `NULL` by the function.
  The argument can be `NULL`.
  The caller of the function takes ownership of the returned data, and is responsible for freeing it.
  The value is a NUL terminated UTF-8 string.

`fragment`

  Type: `gchar**`

  On return, contains the fragment, or `NULL`.

  The argument will be set by the function.
  The argument can be set to `NULL` by the function.
  The argument can be `NULL`.
  The caller of the function takes ownership of the returned data, and is responsible for freeing it.
  The value is a NUL terminated UTF-8 string.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the function if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `gboolean`

`TRUE` if `uri_ref` parsed successfully, `FALSE` on error.