Functions | |
char * | qStrTrim (char *str) |
Remove white spaces(including CR, LF) from head and tail of the string. | |
char * | qStrTrimTail (char *str) |
Remove tailing white spaces(including CR, LF) of the string. | |
char * | qStrReplace (const char *mode, char *srcstr, const char *tokstr, const char *word) |
Replace string or tokens as word from source string with given mode. | |
char * | qStrCpy (char *dst, size_t dstsize, const char *src, size_t nbytes) |
Copies at most len characters from src into dst then append ”. | |
char * | qStrUpper (char *str) |
Convert character to bigger character. | |
char * | qStrLower (char *str) |
Convert character to lower character. | |
char * | qStrCaseStr (const char *s1, const char *s2) |
Find a substring with no case-censitive. | |
char * | qStrRev (char *str) |
Reverse the order of characters in the string. | |
char * | qStrTok (char *str, const char *delimiters, char *retstop) |
Split string into tokens. | |
Q_ENTRY * | qStrTokenizer (char *str, const char *delimiters) |
String Tokenizer. | |
char * | qStrCommaNumber (int number) |
Convert integer to comma string. | |
char * | qStrCatf (char *str, const char *format,…) |
Append formatted string to the end of the source str. | |
char * | qStrDupBetween (const char *str, const char *start, const char *end) |
Duplicate a substing set. | |
char * | qStrUnique (const char *seed) |
Generate unique id. | |
bool | qStrIsAlnum (const char *str) |
Test for an alpha-numeric string. | |
char * | qStrConvEncoding (const char *str, const char *fromcode, const char *tocode, float mag) |
Convert character encoding. |
char* qStrTrim | ( | char * | str | ) |
Remove white spaces(including CR, LF) from head and tail of the string.
str | source string |
char* qStrTrimTail | ( | char * | str | ) |
Remove tailing white spaces(including CR, LF) of the string.
str | source string |
char* qStrReplace | ( | const char * | mode, | |
char * | srcstr, | |||
const char * | tokstr, | |||
const char * | word | |||
) |
Replace string or tokens as word from source string with given mode.
mode | replacing mode | |
srcstr | source string | |
tokstr | token or string | |
word | target word to be replaced |
If ‘s’ is given instead of ‘t’. Token string will be analyzed only one chunk word. So the replacement will be occured when the case of whole word matched.
Second character is used to decide returning memory type and can be ‘n’ or ‘r’ which are stand on [n]ew and [r]eplace.
When ‘n’ is given the result will be placed into new array so you should free the return string after using. Instead of this, you can also use ‘r’ character to modify source string directly. In this case, given source string should have enough space. Be sure that untouchable value can not be used for source string.
So there are four associatable modes such like below.
Mode “tn” : [t]oken replacing & putting the result into [n]ew array. Mode “tr” : [t]oken replacing & [r]eplace source string directly. Mode “sn” : [s]tring replacing & putting the result into [n]ew array. Mode “sr” : [s]tring replacing & [r]eplace source string directly.
char srcstr[256], *retstr; char mode[4][2+1] = {"tn", "tr", "sn", "sr"}; for(i = 0; i < 4; i++) { strcpy(srcstr, "Welcome to the qDecoder project."); printf("before %s : srcstr = %sn", mode[i], srcstr); retstr = qStrReplace(mode[i], srcstr, "the", "_"); printf("after %s : srcstr = %sn", mode[i], srcstr); printf(" retstr = %snn", retstr); if(mode[i][1] == 'n') free(retstr); } --[Result]-- before tn : srcstr = Welcome to the qDecoder project. after tn : srcstr = Welcome to the qDecoder project. retstr = W_lcom_ _o ___ qD_cod_r proj_c_. before tr : srcstr = Welcome to the qDecoder project. after tr : srcstr = W_lcom_ _o ___ qD_cod_r proj_c_. retstr = W_lcom_ _o ___ qD_cod_r proj_c_. before sn : srcstr = Welcome to the qDecoder project. after sn : srcstr = Welcome to the qDecoder project. retstr = Welcome to _ qDecoder project. before sr : srcstr = Welcome to the qDecoder project. after sr : srcstr = Welcome to _ qDecoder project. retstr = Welcome to _ qDecoder project.
char* qStrCpy | ( | char * | dst, | |
size_t | dstsize, | |||
const char * | src, | |||
size_t | nbytes | |||
) |
Copies at most len characters from src into dst then append ”.
dst | a pointer of the string to be copied | |
dstsize | size of dst | |
src | a pointer of source string | |
nbytes | bytes to copy |
char* qStrUpper | ( | char * | str | ) |
Convert character to bigger character.
str | a pointer of source string |
char* qStrLower | ( | char * | str | ) |
Convert character to lower character.
str | a pointer of source string |
char* qStrCaseStr | ( | const char * | s1, | |
const char * | s2 | |||
) |
Find a substring with no case-censitive.
big | a pointer of source string | |
small | a pointer of substring |
char* qStrRev | ( | char * | str | ) |
Reverse the order of characters in the string.
str | a pointer of source string |
char* qStrTok | ( | char * | str, | |
const char * | delimiters, | |||
char * | retstop | |||
) |
Split string into tokens.
str | source string | |
delimiters | string that specifies a set of delimiters that may surround the token being extracted | |
retstop | stop delimiter character will be stored. it can be NULL if you don’t want to know. |
Q_ENTRY* qStrTokenizer | ( | char * | str, | |
const char * | delimiters | |||
) |
String Tokenizer.
str | source string | |
delimiters | string that specifies a set of delimiters that may surround the token being extracted |
FILE *fp = fopen("/etc/passwd", "r"); char *buf; while((buf = qFileReadLine(fp)) != NULL) { qStrTrimTail(buf); Q_ENTRY *tokens = qStrTokenizer(buf, ":"); printf("%sn", qEntryGetStr(tokens, "1")); qEntryFree(tokens); } fclose(fp);
char* qStrCommaNumber | ( | int | number | ) |
Convert integer to comma string.
number | integer |
char* qStrCatf | ( | char * | str, | |
const char * | format, | |||
… | ||||
) |
Append formatted string to the end of the source str.
str | a pointer of original string | |
format | string format to append |
char* qStrDupBetween | ( | const char * | str, | |
const char * | start, | |||
const char * | end | |||
) |
Duplicate a substing set.
str | a pointer of original string | |
start | substring which is started with this | |
end | substring which is ended with this |
char* qStrUnique | ( | const char * | seed | ) |
Generate unique id.
seed | additional seed string. this can be NULL |
bool qStrIsAlnum | ( | const char * | str | ) |
Test for an alpha-numeric string.
str | a pointer of string |
qCharEncode("�ѱ�", "EUC-KR", "UTF-8", 1.5);
char* qStrConvEncoding | ( | const char * | str, | |
const char * | fromcode, | |||
const char * | tocode, | |||
float | mag | |||
) |
Convert character encoding.
str | additional seed string. this can be NULL | |
fromcode | encoding type of str | |
tocode | encoding to convert | |
mag | magnification between fromcode and tocode |
qCharEncode("�ѱ�", "EUC-KR", "UTF-8", 1.5);
[Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference] |