String library

string operators

STRCopy
copy a string to another place
STRCopySafe
copy a string to another place, as much as possible
STRLength
get the length of a string
STRAppend
append a string to another string
STRAppendSafe
append a string to another string, as much as possible
STRCompareCD
compare two strings, Case Dependant (CD)
STRCompareCI
compare two strings, Case Independant (CI)
STRSameCD
see if two strings are the same CD, faster than compare
STRSameCI
see if two strings are the same CI, faster than compare
STRSearchCD
search first occurence of on string in another, CD
STRSearchCI
search first occurence of on string in another, CD
STRUpper
convert a string to upper case
STRLower
convert a string to lower case
STRBreak
break a string up into a list of pointers to strings e.g. STRBreak(params,&argv) !!
STRDuplicate
duplicate a string

conversion routines

STRFormatGet
get data (in variables) using format string
STRFormatPut
convert any kind of info to a string
STRFormatPutSafe
Safe version of STRFormatPut. In this routine, the length of the string to be filled in has to be passed.

standard function

because it is used so often, we have also provided this standard routine. It does not follow the standard rules for parameter passing and returning as it returns the length of the string (and not an error). However, this routine can almost be considered as a builtin function (like sizeof).
strlen
return the length of the string

Format strings :

STRFormatGet

The format string may contain :

When a '*' is present, then no assignment to an argument is made (and no argument is needed). An input field is a string of non-whitespace characters, it extends either to the next whitespace character, or until the field width is exhausted (or an unrecognized character is encountered).

The conversion character indicates the interpretation of the input field. The corresponding argument must be a pointer. If the conversion character of an integer is preceded by a 'h', the argument is taken as a pointer to short rather than int, or long instead of int (for 'l').
Conversion characters are :

char - argument type, input data
d
int *; decimal integer
i
int *; integer, the integer may be octal (leading '0') or hex (leading '0x' or '0X')
o
int *; octal integer, with or without leading '0'
u
unsigned int *; unsigned decimal
x
int *; hex integer, with or without '0x' or '0X'
c
char *; The next input characters are placed in the indicated array, up to the number given in the field width, the default is 1. No terminating '\0' is added !
s
char *; read a string of non-whitespace chars (not quoted). A terminating '\0' will be added. The array pointed to should be large enough
e,f,g
double *; reads a floating point number, which can include a sign, decimal point and exponent.
p
void **; reads a pointer value.
n
int *; writes into the argument the number of characters read so far from the string. Does not increment the count. No chars from the string are matched.
[..]
char *; matches the longest non-empty string of input characters from the set between brackets. A '\0' is added. [^]..] includes ']' in the set.
[^..]
char *; matches the longest non-empty string of input characters not from the set between brackets. A '\0' is added. [^]..] includes ']' in the set.
%
matches witha '%', no assignment is made.

STRFormatPut and STRFormatPutSafe

The format contains ordinary characters, which are copied to the string, and conversion specifications, which start with a % character, and end with a conversion character. In between there may be (in the order as given here) Conversion characters are (char - argument type, converted to) :
d,i
int; signed decimal
o
int; unsigned octal (without leading zero)
x,X
int; usigned hex, without '0x', lower case for x, upper for X
u
int; unsigned decimal
c
int; single character
s
char *; characters from the string are printed until a '\0' is encountered, or the number of chars indicated by precision printed.
f
double; decimal notation of the form [-]mmm.ddd, where the number of d's is given by the precision. The default precision is 6 (or 14 when 'L' is used). A precision of 0 suppresses the decimal point.
e,E
double; decimal notation of the form [-]m.dddesxx, where the number of d's is given by the precision. The default precision is 6 (or 14 when 'L' is used). A precision of 0 suppresses the decimal point. The e is lower case for 'e', upper for 'E'. The s is the sign of the exponent.
g,G
double; %e or %E is used when the exponent is less than -4 or greater than or equal to the precision. Otherwise %f is used. Trailing zeros and trailing decimal point are not printed.
p
void *; print as a pointer (hex)
n
int *; the number of characters written so far by this call is filled into the argument. No argument is converted.
%
no argument is converted, put '%' in the string.