gmerlin
|
String utilities. More...
Topics | |
Misc stuff | |
Functions | |
char * | bg_toupper (const char *str) |
Convert an UTF-8 string to uppercase. | |
int | bg_string_is_url (const char *str) |
Check if a string looks like an URL. | |
int | bg_url_split (const char *url, char **protocol, char **user, char **password, char **hostname, int *port, char **path) |
Split an URL into their parts. | |
void | bg_url_get_vars (char *path, gavl_metadata_t *vars) |
void | bg_get_filename_hash (const char *gml, char ret[33]) |
Get MD5 hash of a filename. | |
char * | bg_sprintf (const char *format,...) __attribute__((format(printf |
Print into a string. | |
char char ** | bg_strbreak (const char *str, char delim) |
Break a string into substrings. | |
void | bg_strbreak_free (char **retval) |
Free a substrings array. | |
char * | bg_scramble_string (const char *str) |
Scramble a string. | |
char * | bg_descramble_string (const char *str) |
Descramble a string. | |
char * | bg_string_to_uri (const char *pos1, int len) |
Convert a binary string (in system charset) to an URI. | |
char * | bg_uri_to_string (const char *pos1, int len) |
Convert an URI to a a binary string (in system charset) | |
char ** | bg_urilist_decode (const char *str, int len) |
Decode an URI list. | |
void | bg_urilist_free (char **uri_list) |
Free an URI list. | |
char * | bg_system_to_utf8 (const char *str, int len) |
Convert a string from the system character set to UTF-8. | |
char * | bg_utf8_to_system (const char *str, int len) |
Convert a string from UTF-8 to the system character set. | |
const char * | bg_get_language_name (const char *iso) |
Get a language name. | |
int | bg_string_match (const char *str, const char *key_list) |
Check if a string occurs in a space-separated list of strings. | |
wchar_t * | bg_str_to_wchar (const char *str) |
Convert a multibyte string to a wide character string. | |
char * | bg_wchar_to_str (const wchar_t *wstr) |
Convert a wide character string to a byte string. | |
char * | bg_capitalize (const char *str) |
Capitalize the first character of each word in a string. | |
char * | bg_strip_space (char *str) |
Strip leading and trailing whitespace from a string. | |
String utilities.
char * bg_toupper | ( | const char * | str | ) |
Convert an UTF-8 string to uppercase.
str | String |
int bg_string_is_url | ( | const char * | str | ) |
Check if a string looks like an URL.
str | A string |
This checks mostly for the occurrence of "://" at a location, where it makes sense.
int bg_url_split | ( | const char * | url, |
char ** | protocol, | ||
char ** | user, | ||
char ** | password, | ||
char ** | hostname, | ||
int * | port, | ||
char ** | path ) |
Split an URL into their parts.
url | An URL |
protocol | Protocol (returned) |
user | Username (returned) |
password | Password (returned) |
hostname | Hostname (returned) |
port | Port (returned) |
path | Path (returned) |
This parses an url in the form <protocol>://<user@password><host><:port><path>. All arguments for returning the path can be NULL. port will be set to -1 if if doesn't occur in the URL. All strings must be freed when non-NULL after the call.
void bg_get_filename_hash | ( | const char * | gml, |
char | ret[33] ) |
Get MD5 hash of a filename.
gml | |
ret | Returns the MD5 sum |
This creates an MD5 hash of a gml. For regular files this is compatible with the thumbnailing specification
char * bg_sprintf | ( | const char * | format, |
... ) |
Print into a string.
format | printf like format |
All other arguments must match the format like in printf. This function allocates the returned string, thus it must be freed by the caller.
char char ** bg_strbreak | ( | const char * | str, |
char | delim ) |
Break a string into substrings.
str | String |
delim | Delimiter for the substrings |
Free the result with bg_strbreak_free.
void bg_strbreak_free | ( | char ** | retval | ) |
Free a substrings array.
retval | Array |
Use this for substring arrays returned by bg_strbreak.
char * bg_scramble_string | ( | const char * | str | ) |
Scramble a string.
str | String to be scrambled |
Note: Don't even think about using this for security sensitive stuff. It's for saving passwords in files, which should be readable by the the owner only.
char * bg_descramble_string | ( | const char * | str | ) |
Descramble a string.
str | String to be descrambled |
Note: Don't even think about using this for security sensitive stuff. It's for saving passwords in files, which should be readable by the the owner only.
char * bg_string_to_uri | ( | const char * | pos1, |
int | len ) |
Convert a binary string (in system charset) to an URI.
pos1 | The string |
len | or -1 |
This e.g. replaces " " by "%20".
char * bg_uri_to_string | ( | const char * | pos1, |
int | len ) |
Convert an URI to a a binary string (in system charset)
pos1 | The string |
len | or -1 |
This e.g. replaces "%20" by " ".
char ** bg_urilist_decode | ( | const char * | str, |
int | len ) |
Decode an URI list.
str | String |
len | Length of the string or -1 |
This one decodes a string of MIME type text/urilist into a gmerlin usable array of location strings. The returned array is NULL terminated, it must be freed by the caller with bg_urilist_free.
void bg_urilist_free | ( | char ** | uri_list | ) |
Free an URI list.
uri_list | Decoded URI list returned by bg_uri_to_string |
char * bg_system_to_utf8 | ( | const char * | str, |
int | len ) |
Convert a string from the system character set to UTF-8.
str | String |
len | Length or -1 |
The "system charset" is obtained with nl_langinfo().
char * bg_utf8_to_system | ( | const char * | str, |
int | len ) |
Convert a string from UTF-8 to the system character set.
str | String |
len | Length or -1 |
The "system charset" is obtained with nl_langinfo().
const char * bg_get_language_name | ( | const char * | iso | ) |
Get a language name.
iso | An iso-639 3 character code |
int bg_string_match | ( | const char * | str, |
const char * | key_list ) |
Check if a string occurs in a space-separated list of strings.
str | String |
key_list | Space separated list of keys |
wchar_t * bg_str_to_wchar | ( | const char * | str | ) |
Convert a multibyte string to a wide character string.
str | String |
char * bg_wchar_to_str | ( | const wchar_t * | wstr | ) |
Convert a wide character string to a byte string.
wstr | String |
char * bg_capitalize | ( | const char * | str | ) |
Capitalize the first character of each word in a string.
str | String |
char * bg_strip_space | ( | char * | str | ) |
Strip leading and trailing whitespace from a string.
str | String |