NetSurf
|
Interface to utility string handling. More...
Go to the source code of this file.
Functions | |
char * | squash_whitespace (const char *s) |
Replace consecutive whitespace with a single space. More... | |
char * | cnv_space2nbsp (const char *s) |
Converts NUL terminated UTF-8 encoded string s containing zero or more spaces (char 32) or TABs (char 9) to non-breaking spaces (0xC2 + 0xA0 in UTF-8 encoding). More... | |
char * | human_friendly_bytesize (unsigned long long int bytesize) |
Create a human readable representation of a size in bytes. More... | |
nserror | vsnstrjoin (char **str, size_t *size, char sep, size_t nelm, va_list ap) |
Generate a string from one or more component elements separated with a single value. More... | |
nserror | snstrjoin (char **str, size_t *size, char sep, size_t nelm,...) |
Generate a string from one or more component elements separated with a single value. More... | |
Interface to utility string handling.
Definition in file string.h.
char * cnv_space2nbsp | ( | const char * | s | ) |
Converts NUL terminated UTF-8 encoded string s containing zero or more spaces (char 32) or TABs (char 9) to non-breaking spaces (0xC2 + 0xA0 in UTF-8 encoding).
Caller needs to free() result. Returns NULL in case of error. No checking is done on validness of the UTF-8 input string.
Definition at line 67 of file utils.c.
Referenced by box_select_add_option(), and ro_gui_window_prepare_form_select_menu().
char * human_friendly_bytesize | ( | unsigned long long int | bytesize | ) |
Create a human readable representation of a size in bytes.
Does a simple conversion which assumes the user speaks English. The buffer returned is one of three static ones so may change each time this call is made. Don't store the buffer for later use. It's done this way for convenience and to fight possible memory leaks, it is not necessarily pretty.
bytesize | The size in bytes. |
Definition at line 209 of file utils.c.
References BYTESIZE_BUFFER_SIZE, and messages_get().
Referenced by ami_download_check_overwrite(), fetch_curl_progress(), gui_download_window_create(), gui_download_window_data(), gui_download_window_done(), NSDownloadWindow::NSDownloadWindow(), nsgtk_download_info_to_string(), nsgtk_download_store_update_item(), nsws_download_update_label(), NSDownloadWindow::Progress(), and ro_gui_download_update_status().
nserror snstrjoin | ( | char ** | str, |
size_t * | size, | ||
char | sep, | ||
size_t | nelm, | ||
... | |||
) |
Generate a string from one or more component elements separated with a single value.
This is similar in intent to the Perl join function creating a single delimited string from an array of several.
[in,out] | str | pointer to string pointer if this is NULL enough storage will be allocated for the complete path. |
[in,out] | size | The size of the space available if str not NULL on input and if not NULL set to the total output length on output. |
[in] | sep | The character to separate the elements with. |
[in] | nelm | The number of elements up to a maximum of 16. |
[in] | ... | The elements of the path as string pointers. |
Definition at line 179 of file utils.c.
References vsnstrjoin().
char * squash_whitespace | ( | const char * | s | ) |
Replace consecutive whitespace with a single space.
s | source string |
Definition at line 38 of file utils.c.
Referenced by box_construct_element(), box_construct_text(), box_image(), box_select_add_option(), and html_process_title().
nserror vsnstrjoin | ( | char ** | str, |
size_t * | size, | ||
char | sep, | ||
size_t | nelm, | ||
va_list | ap | ||
) |
Generate a string from one or more component elements separated with a single value.
This is similar in intent to the perl join function creating a single delimited string from an array of several.
[in,out] | str | pointer to string pointer if this is NULL enough storage will be allocated for the complete path. |
[in,out] | size | The size of the space available if str not NULL on input and if not NULL set to the total output length on output. |
[in] | sep | The character to separate the elements with. |
[in] | nelm | The number of elements up to a maximum of 16. |
[in] | ap | The elements of the path as string pointers. |
Definition at line 107 of file utils.c.
References NSERROR_BAD_PARAMETER, NSERROR_NOMEM, NSERROR_NOSPACE, and NSERROR_OK.
Referenced by atari_mkpath(), posix_vmkpath(), snstrjoin(), and windows_mkpath().