Main Page Widgets glibmm Namespaces Book

# URI Utilities

Various uri-related functions. More...

## Functions
std::string | Glib::uri_unescape_string (const std::string& escaped_string, const std::string& illegal_characters=std::string())
| Unescapes a whole escaped string.
std::string | Glib::uri_parse_scheme (const std::string& uri)
| Gets the scheme portion of a URI.
std::string | Glib::uri_escape_string (const std::string& unescaped, const std::string& reserved_chars_allowed=std::string(), bool allow_utf8=true)
| Escapes a string for use in a URI.

## Detailed Description

Various uri-related functions.

## Function Documentation

std::string Glib::uri_escape_string | ( | const std::string & | unescaped,
|  | const std::string & | reserved_chars_allowed = `std::string()`,
|  | bool | allow_utf8 = `true` |
| ) |  |  |

Escapes a string for use in a URI.

Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical characters plus dash, dot, underscore and tilde) are escaped. But if you specify characters in reserved_chars_allowed they are not escaped. This is useful for the "reserved" characters in the URI specification, since those are allowed unescaped in some portions of a URI.

Parameters:

  | unescaped | The unescaped input string.
  | reserved_chars_allowed | A string of reserved characters that are allowed to be used.
  | allow_utf8 | true if the result can include UTF-8 characters.

Returns:
  An escaped version of unescaped.

Since glibmm 2.16:

std::string Glib::uri_parse_scheme | ( | const std::string & | uri | ) |

Gets the scheme portion of a URI.

RFC 3986 decodes the scheme as:

     URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

Common schemes include "file", "http", "svn+ssh", etc.

Parameters:

  | uri |

Returns:
  The "Scheme" component of the URI, or an empty string on error.

Since glibmm 2.16:

std::string Glib::uri_unescape_string | ( | const std::string & | escaped_string,
|  | const std::string & | illegal_characters = `std::string()` |
| ) |  |  |

Unescapes a whole escaped string.

If any of the characters in illegal_characters or the character zero appears as an escaped character in escaped_string then that is an error and an empty string will be returned. This is useful it you want to avoid, for instance, having a slash being expanded in an escaped path element, which might confuse pathname handling.

Parameters:

  | escaped_string | An escaped string to be unescaped.
  | illegal_characters | An optional string of illegal characters not to be allowed.

Returns:
  An unescaped version of escaped_string.

Since glibmm 2.16: