NetSurf
|
Helpers for ASCII string handling. More...
#include <errno.h>
#include <stdlib.h>
#include <limits.h>
Go to the source code of this file.
Functions | |
static bool | ascii_is_space (char c) |
Test whether a character is a whitespace character. More... | |
static bool | ascii_is_alpha_lower (char c) |
Test whether a character is lower-case alphabetical. More... | |
static bool | ascii_is_alpha_upper (char c) |
Test whether a character is upper-case alphabetical. More... | |
static bool | ascii_is_alpha (char c) |
Test whether a character is alphabetical (upper or lower case). More... | |
static bool | ascii_is_digit (char c) |
Test whether a character is a decimal digit. More... | |
static bool | ascii_is_sign (char c) |
Test whether a character is a positive/negative numerical sign. More... | |
static bool | ascii_is_alphanumerical (char c) |
Test whether a character is alphanumerical (upper or lower case). More... | |
static bool | ascii_is_af_lower (char c) |
Test whether a character is 'a' to 'f' (lowercase). More... | |
static bool | ascii_is_hex_lower (char c) |
Test whether a character is hexadecimal (lower case). More... | |
static bool | ascii_is_af_upper (char c) |
Test whether a character is 'A' to 'F' (uppercase). More... | |
static bool | ascii_is_hex_upper (char c) |
Test whether a character is hexadecimal (upper case). More... | |
static bool | ascii_is_hex (char c) |
Test whether a character is hexadecimal (upper or lower case). More... | |
static int | ascii_hex_to_value (char c) |
Convert a hexadecimal character to its value. More... | |
static int | ascii_hex_to_value_2_chars (char c1, char c2) |
Converts two hexadecimal characters to a single number. More... | |
static char | ascii_to_lower (char c) |
Convert an upper case character to lower case. More... | |
static char | ascii_to_upper (char c) |
Convert a lower case character to upper case. More... | |
static size_t | ascii_count_alpha_lower (const char *str) |
Count consecutive lower case alphabetical characters in string. More... | |
static size_t | ascii_count_alpha_upper (const char *str) |
Count consecutive upper case alphabetical characters in string. More... | |
static size_t | ascii_count_alpha (const char *str) |
Count consecutive alphabetical characters in string (upper or lower case). More... | |
static size_t | ascii_count_digit (const char *str) |
Count consecutive decial digit characters in string. More... | |
static size_t | ascii_count_digit_or_colon (const char *str) |
Count consecutive characters either decimal digit or colon in string. More... | |
static bool | ascii_strings_equal_caseless (const char *s1, const char *s2) |
Test for string equality (case insensitive). More... | |
static bool | ascii_strings_equal (const char *s1, const char *s2) |
Test for string equality (case sensitive). More... | |
static size_t | ascii_strings_count_equal_caseless (const char *s1, const char *s2) |
Count consecutive equal ascii characters (case insensitive). More... | |
static size_t | ascii_strings_count_equal (const char *s1, const char *s2) |
Count consecutive equal ascii characters (case sensitive). More... | |
static size_t | ascii_string_to_int (const char *str, int *res) |
Parse an int out of a string. More... | |
Helpers for ASCII string handling.
These helpers for string parsing will have the correct effect for parsing ASCII text (as used by most web specs), regardless of system locale.
Definition in file ascii.h.
|
inlinestatic |
Count consecutive alphabetical characters in string (upper or lower case).
[in] | str | String to count characters in. |
str
. Definition at line 267 of file ascii.h.
References ascii_is_alpha(), and count().
Referenced by time__get_date().
|
inlinestatic |
Count consecutive lower case alphabetical characters in string.
[in] | str | String to count characters in. |
str
. Definition at line 237 of file ascii.h.
References ascii_is_alpha_lower(), and count().
|
inlinestatic |
Count consecutive upper case alphabetical characters in string.
[in] | str | String to count characters in. |
str
. Definition at line 252 of file ascii.h.
References ascii_is_alpha_upper(), and count().
|
inlinestatic |
Count consecutive decial digit characters in string.
[in] | str | String to count characters in. |
str
. Definition at line 282 of file ascii.h.
References ascii_is_digit(), and count().
Referenced by time__get_date().
|
inlinestatic |
Count consecutive characters either decimal digit or colon in string.
[in] | str | String to count characters in. |
str
. Definition at line 297 of file ascii.h.
References ascii_is_digit(), and count().
Referenced by time__parse_hh_mm_ss().
|
inlinestatic |
Convert a hexadecimal character to its value.
[in] | c | Character to convert. |
Definition at line 176 of file ascii.h.
References ascii_is_af_lower(), ascii_is_af_upper(), and ascii_is_digit().
Referenced by ascii_hex_to_value_2_chars().
|
inlinestatic |
Converts two hexadecimal characters to a single number.
[in] | c1 | most significant hex digit. |
[in] | c2 | least significant hex digit. |
Definition at line 198 of file ascii.h.
References ascii_hex_to_value().
|
inlinestatic |
Test whether a character is 'a' to 'f' (lowercase).
[in] | c | Character to test. |
c
is 'a' to 'f' (lowercase), else false. Definition at line 119 of file ascii.h.
Referenced by ascii_hex_to_value(), ascii_is_hex(), and ascii_is_hex_lower().
|
inlinestatic |
Test whether a character is 'A' to 'F' (uppercase).
[in] | c | Character to test. |
c
is 'A' to 'F' (uppercase), else false. Definition at line 141 of file ascii.h.
Referenced by ascii_hex_to_value(), ascii_is_hex(), and ascii_is_hex_upper().
|
inlinestatic |
Test whether a character is alphabetical (upper or lower case).
[in] | c | Character to test. |
c
is alphabetical, else false. Definition at line 75 of file ascii.h.
References ascii_is_alpha_lower(), and ascii_is_alpha_upper().
Referenced by ascii_count_alpha(), ascii_is_alphanumerical(), time__get_date(), and urldb_get_search_tree_direct().
|
inlinestatic |
Test whether a character is lower-case alphabetical.
[in] | c | Character to test. |
c
is lower-case alphabetical, else false. Definition at line 53 of file ascii.h.
Referenced by ascii_count_alpha_lower(), ascii_is_alpha(), and ascii_to_upper().
|
inlinestatic |
Test whether a character is upper-case alphabetical.
[in] | c | Character to test. |
c
is upper-case alphabetical, else false. Definition at line 64 of file ascii.h.
Referenced by ascii_count_alpha_upper(), ascii_is_alpha(), and ascii_to_lower().
|
inlinestatic |
Test whether a character is alphanumerical (upper or lower case).
[in] | c | Character to test. |
c
is alphanumerical, else false. Definition at line 108 of file ascii.h.
References ascii_is_alpha(), and ascii_is_digit().
|
inlinestatic |
Test whether a character is a decimal digit.
[in] | c | Character to test. |
c
is a decimal digit, else false. Definition at line 86 of file ascii.h.
Referenced by ascii_count_digit(), ascii_count_digit_or_colon(), ascii_hex_to_value(), ascii_is_alphanumerical(), ascii_is_hex(), ascii_is_hex_lower(), ascii_is_hex_upper(), time__get_date(), and urldb_parse_avpair().
|
inlinestatic |
Test whether a character is hexadecimal (upper or lower case).
[in] | c | Character to test. |
c
is hexadecimal, else false. Definition at line 163 of file ascii.h.
References ascii_is_af_lower(), ascii_is_af_upper(), and ascii_is_digit().
Referenced by url_unescape().
|
inlinestatic |
Test whether a character is hexadecimal (lower case).
[in] | c | Character to test. |
c
is hexadecimal, else false. Definition at line 130 of file ascii.h.
References ascii_is_af_lower(), and ascii_is_digit().
|
inlinestatic |
Test whether a character is hexadecimal (upper case).
[in] | c | Character to test. |
c
is hexadecimal, else false. Definition at line 152 of file ascii.h.
References ascii_is_af_upper(), and ascii_is_digit().
|
inlinestatic |
Test whether a character is a positive/negative numerical sign.
[in] | c | Character to test. |
c
is a sign, else false. Definition at line 97 of file ascii.h.
Referenced by time__parse_number().
|
inlinestatic |
Test whether a character is a whitespace character.
[in] | c | Character to test. |
c
is whitespace, else false. Definition at line 40 of file ascii.h.
Referenced by box_extract_link(), box_parse_multi_lengths(), box_text_transform(), form_acceptable_charset(), gtk_fetch_filetype_init(), html_process_inserted_meta(), and monkey_fetch_filetype_init().
|
inlinestatic |
Parse an int out of a string.
[in] | str | String to parse integer out of. |
[out] | res | Returns parsed integer. |
str
. Returning 0 indicates failure to parse an integer out of the string. Definition at line 397 of file ascii.h.
References strtoll().
Referenced by time__parse_number().
|
inlinestatic |
|
inlinestatic |
Count consecutive equal ascii characters (case insensitive).
[in] | s1 | First string to compare. |
[in] | s2 | Second string to compare. |
Definition at line 354 of file ascii.h.
References ascii_to_lower().
Referenced by time__parse_month(), time__parse_timezone(), and time__parse_weekday().
|
inlinestatic |
|
inlinestatic |
Test for string equality (case insensitive).
[in] | s1 | First string to compare. |
[in] | s2 | Second string to compare. |
Definition at line 314 of file ascii.h.
References ascii_to_lower().
|
inlinestatic |
Convert an upper case character to lower case.
If the given character is not upper case alphabetical, it is returned unchanged.
[in] | c | Character to convert. |
c
else c
. Definition at line 212 of file ascii.h.
References ascii_is_alpha_upper().
Referenced by ascii_strings_count_equal_caseless(), ascii_strings_equal_caseless(), box_text_transform(), fetch_filetype(), monkey_fetch_filetype(), save_complete_rewrite_stylesheet_urls(), and urldb_get_search_tree_direct().
|
inlinestatic |
Convert a lower case character to upper case.
If the given character is not lower case alphabetical, it is returned unchanged.
[in] | c | Character to convert. |
c
else c
. Definition at line 226 of file ascii.h.
References ascii_is_alpha_lower().
Referenced by box_text_transform(), content_textsearch_find_pattern(), and form_acceptable_charset().