ELinks 0.16.1.1
|
Conversion functions. More...
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include "elinks.h"
#include "intl/charsets.h"
#include "util/conv.h"
#include "util/error.h"
#include "util/time.h"
Functions | |
NONSTATIC_INLINE int | elinks_ulongcat (char *s, unsigned int *slen, unsigned long long number, unsigned int width, unsigned char fillchar, unsigned int base, unsigned int upper) |
This function takes string s and stores the number (of a result width width) in string format there, starting at position [*slen]. | |
NONSTATIC_INLINE int | elinks_longcat (char *s, unsigned int *slen, long long number, unsigned int width, unsigned char fillchar, unsigned int base, unsigned int upper) |
Similar to elinks_ulongcat() but for long number. | |
struct string * | add_string_replace (struct string *string, char *src, int len, unsigned char replaceable, unsigned char replacement) |
struct string * | add_html_to_string (struct string *string, const char *src2, int len) |
struct string * | add_cp_html_to_string (struct string *string, int src_codepage, const char *src, int len) |
struct string * | add_quoted_to_string (struct string *string, const char *src, int len) |
struct string * | add_shell_quoted_to_string (struct string *string, const char *src, int len) |
struct string * | add_shell_safe_to_string (struct string *string, const char *cmd, int cmdlen) |
long | strtolx (char *str, char **end) |
int | month2num (const char *str) |
Return 0 if starting with jan, 11 for dec, -1 for failure. | |
void | clr_spaces (char *str2) |
This function drops control chars, nbsp char and limit the number of consecutive space chars to one. | |
void | sanitize_title (char *title) |
Replace invalid chars in title with ' ' and trim all starting/ending spaces. | |
int | sanitize_url (char *url) |
Returns 0 if url contains invalid chars, 1 if ok. | |
int | c_tolower (int c) |
int | c_toupper (int c) |
int | c_isupper (int c) |
int | c_islower (int c) |
Conversion functions.
|
|
int c_islower | ( | int | c | ) |
int c_isupper | ( | int | c | ) |
int c_tolower | ( | int | c | ) |
int c_toupper | ( | int | c | ) |
void clr_spaces | ( | char * | str2 | ) |
This function drops control chars, nbsp char and limit the number of consecutive space chars to one.
It modifies its argument.
NONSTATIC_INLINE int elinks_longcat | ( | char * | s, |
unsigned int * | slen, | ||
long long | number, | ||
unsigned int | width, | ||
unsigned char | fillchar, | ||
unsigned int | base, | ||
unsigned int | upper ) |
Similar to elinks_ulongcat() but for long
number.
NONSTATIC_INLINE int elinks_ulongcat | ( | char * | s, |
unsigned int * | slen, | ||
unsigned long long | number, | ||
unsigned int | width, | ||
unsigned char | fillchar, | ||
unsigned int | base, | ||
unsigned int | upper ) |
This function takes string s and stores the number (of a result width width) in string format there, starting at position [*slen].
If the number would take more space than width, it is truncated and only the last digits of it are inserted to the string. If the number takes less space than width, it is padded by fillchar from left. base defined which base should be used (10, 16, 8, 2, ...) upper selects either hexa uppercased chars or lowercased chars.
A NUL char is always added at the end of the string. s must point to a sufficiently large memory space, at least *slen + width + 1.
Examples:
Note that this function exists to provide a fast and efficient, however still quite powerful alternative to sprintf(). It is optimized for speed and is MUCH faster than sprintf(). If you can use it, use it ;-). But do not get too enthusiastic, do not use it in cases where it would break i18n.
int month2num | ( | const char * | month | ) |
Return 0 if starting with jan, 11 for dec, -1 for failure.
month must be a lowercased string.
void sanitize_title | ( | char * | title | ) |
Replace invalid chars in title with ' ' and trim all starting/ending spaces.
update_bookmark() assumes this function does not switch translation tables.
int sanitize_url | ( | char * | url | ) |
Returns 0 if url contains invalid chars, 1 if ok.
It trims starting/ending spaces.
long strtolx | ( | char * | str, |
char ** | end ) |