mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 15:48:54 +02:00
Add g_str_is_ascii()
Add a function for checking if a string is pure ASCII. https://bugzilla.gnome.org/show_bug.cgi?id=709753
This commit is contained in:
@@ -1302,6 +1302,7 @@ g_vasprintf
|
|||||||
g_printf_string_upper_bound
|
g_printf_string_upper_bound
|
||||||
|
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
|
g_str_is_ascii
|
||||||
g_ascii_isalnum
|
g_ascii_isalnum
|
||||||
g_ascii_isalpha
|
g_ascii_isalpha
|
||||||
g_ascii_iscntrl
|
g_ascii_iscntrl
|
||||||
|
@@ -1527,6 +1527,29 @@ g_ascii_strup (const gchar *str,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_str_is_ascii:
|
||||||
|
* @string: a string.
|
||||||
|
*
|
||||||
|
* Determines if a string is pure ASCII. A string is pure ASCII if it
|
||||||
|
* contains no bytes with the high bit set.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if @string is ascii
|
||||||
|
*
|
||||||
|
* Since: 2.40
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
g_str_is_ascii (const gchar *string)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
for (i = 0; string[i]; i++)
|
||||||
|
if (string[i] & 0x80)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_strdown:
|
* g_strdown:
|
||||||
* @string: the string to convert.
|
* @string: the string to convert.
|
||||||
|
@@ -195,6 +195,8 @@ GLIB_AVAILABLE_IN_ALL
|
|||||||
gchar* g_ascii_strup (const gchar *str,
|
gchar* g_ascii_strup (const gchar *str,
|
||||||
gssize len) G_GNUC_MALLOC;
|
gssize len) G_GNUC_MALLOC;
|
||||||
|
|
||||||
|
GLIB_AVAILABLE_IN_2_40
|
||||||
|
gboolean g_str_is_ascii (const gchar *str);
|
||||||
|
|
||||||
GLIB_DEPRECATED
|
GLIB_DEPRECATED
|
||||||
gint g_strcasecmp (const gchar *s1,
|
gint g_strcasecmp (const gchar *s1,
|
||||||
|
Reference in New Issue
Block a user