xtralib  0.1.0
A simple header-based drop-in library
string.h
Go to the documentation of this file.
1 
9 #ifndef __XTRA_STRING_H__
10 #define __XTRA_STRING_H__
11 
12 #include <string.h>
13 #include <stdlib.h>
14 
15 #if defined(__APPLE__)
16 #include <wchar.h>
17 #elif defined(__linux__)
18 #include <wchar.h>
19 #include <wctype.h>
20 #endif
21 
22 #define MAX_CHARSET_SIZE 256
23 #define SUB 0x1A // an empty char as not to interfere with '\0'
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 char * strdupl(const char *str);
30 
31 char * strcov(char *str, const char *charset);
32 wchar_t * wcscov(wchar_t *str, const wchar_t *charset);
33 
34 
35 const char * strset(const char *string, const char *charset);
36 const wchar_t * wcsset(const wchar_t *string, const wchar_t *charset);
37 
38 
39 char * strpcat(char *dest, const char *src, size_t pos);
40 wchar_t * wcspcat(wchar_t *dest, const wchar_t *src, size_t pos);
41 
42 char * chrcat(char *dest, const char src);
43 wchar_t * wccat(wchar_t *dest, const wchar_t src);
44 
45 int strchrn(const char *string, char ch);
46 int wcswcn(const wchar_t *string, wchar_t ch);
47 
48 
49 wchar_t * wcsrev(wchar_t *str);
50 char * strpre(char *str, char chr);
51 wchar_t * wcspre(wchar_t *str, wchar_t chr);
52 char * strpres(char *str, char* pre);
53 wchar_t * wcspres(wchar_t *str, wchar_t *pre);
54 
55 wchar_t *iswcsdigit(wchar_t *string);
56 
57 
58 long hash(const char* str);
59 
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif
New functions and types related to string and string manipulation.
wchar_t * wcsrev(wchar_t *str)
Reverses the wide character string.
Definition: string.c:196
int wcswcn(const wchar_t *string, wchar_t ch)
(Wide-char variant) Get number of times that ch appears in string.
Definition: string.c:311
char * strcov(char *str, const char *charset)
Checks if string covers all of charset.
Definition: string.c:32
char * strdupl(const char *str)
Implmentation of 'strdup'.
Definition: string.c:19
wchar_t * iswcsdigit(wchar_t *string)
Confirms that wcstring is entirely composed on numbers.
Definition: string.c:326
char * chrcat(char *dest, const char src)
Concatenate a char on to the end of a string.
Definition: string.c:166
int strchrn(const char *string, char ch)
Get number of times that ch appears in string.
Definition: string.c:295
const char * strset(const char *string, const char *charset)
Checks to see if string contains only characters in charset.
Definition: string.c:88
wchar_t * wcspre(wchar_t *str, wchar_t chr)
Prepends a character to a wide character string.
Definition: string.c:219
char * strpcat(char *dest, const char *src, size_t pos)
concatenate but at a give 'p' position.
Definition: string.c:134