/* Returns: TRUE if the text was valid UTF-8  */
gboolean g_utf8_validate(const char *str, gssize max_len, const gchar **end)
/* Returns: TRUE if the text was valid UTF-8  */
gboolean g_utf8_validate(const char *str, gssize max_len, const gchar **end)
{
  const gchar *p;
  if (max_len < 0)
    p = fast_validate (str);
  else
    p = fast_validate_len (str, max_len);
  if (end)
    *end = p;
  if ((max_len >= 0 && p != str + max_len) ||
      (max_len < 0 && *p != '\0'))
    return FALSE;
  else
    return TRUE;
}