Defines | Functions

String Utilities
[Utilities]

Collaboration diagram for String Utilities:

Defines

#define iup_isdigit(_c)   (_c>='0' && _c<='9')
#define iup_toupper(_c)   ((_c >= 'a' && _c <= 'z')? (_c - 'a') + 'A': _c)
#define iup_tolower(_c)   ((_c >= 'A' && _c <= 'Z')? (_c - 'A') + 'a': _c)
#define IUP_FLOAT2STR   "%.9f"
#define IUP_DOUBLE2STR   "%.18f"

Functions

int iupStrEqual (const char *str1, const char *str2)
int iupStrEqualNoCase (const char *str1, const char *str2)
int iupStrEqualNoCaseNoSpace (const char *str1, const char *str2)
int iupStrEqualPartial (const char *str1, const char *str2)
int iupStrEqualNoCasePartial (const char *str1, const char *str2)
int iupStrBoolean (const char *str)
int iupStrFalse (const char *str)
int iupStrLineCount (const char *str)
const char * iupStrNextLine (const char *str, int *len)
const char * iupStrNextValue (const char *str, int str_len, int *len, char sep)
int iupStrCountChar (const char *str, char c)
char * iupStrDup (const char *str)
char * iupStrDupUntil (const char **str, char c)
void iupStrCopyN (char *dst_str, int dst_max_size, const char *src_str)
char * iupStrGetMemory (int size)
char * iupStrGetLargeMem (int *size)
void iupStrLower (char *dstr, const char *sstr)
void iupStrUpper (char *dstr, const char *sstr)
int iupStrHasSpace (const char *str)
int iupStrIsAscii (const char *str)
char * iupStrReturnStrf (const char *format,...)
char * iupStrReturnStr (const char *str)
char * iupStrReturnBoolean (int i)
char * iupStrReturnChecked (int i)
char * iupStrReturnInt (int i)
char * iupStrReturnFloat (float f)
char * iupStrReturnDouble (double d)
char * iupStrReturnRGB (unsigned char r, unsigned char g, unsigned char b)
char * iupStrReturnRGBA (unsigned char r, unsigned char g, unsigned char b, unsigned char a)
char * iupStrReturnStrStr (const char *str1, const char *str2, char sep)
char * iupStrReturnIntInt (int i1, int i2, char sep)
int iupStrGetFormatPrecision (const char *format)
void iupStrPrintfDoubleLocale (char *str, const char *format, double d, const char *decimal_symbol)
int iupStrToRGB (const char *str, unsigned char *r, unsigned char *g, unsigned char *b)
int iupStrToRGBA (const char *str, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a)
int iupStrToInt (const char *str, int *i)
int iupStrToIntInt (const char *str, int *i1, int *i2, char sep)
int iupStrToFloat (const char *str, float *f)
int iupStrToDouble (const char *str, double *d)
int iupStrToDoubleLocale (const char *str, double *d, const char *decimal_symbol)
int iupStrToFloatFloat (const char *str, float *f1, float *f2, char sep)
int iupStrToDoubleDouble (const char *str, double *f1, double *f2, char sep)
int iupStrToStrStr (const char *str, char *str1, char *str2, char sep)
char * iupStrFileGetExt (const char *file_name)
char * iupStrFileGetTitle (const char *file_name)
char * iupStrFileGetPath (const char *file_name)
char * iupStrFileMakeFileName (const char *path, const char *title)
void iupStrFileNameSplit (const char *filename, char *path, char *title)
int iupStrReplace (char *str, char src, char dst)
void iupStrToUnix (char *str)
void iupStrToMac (char *str)
char * iupStrToDos (const char *str)
char * iupStrConvertToC (const char *str)
void iupStrRemove (char *value, int start, int end, int dir, int utf8)
char * iupStrInsert (const char *value, const char *insert_value, int start, int end, int utf8)
char * iupStrProcessMnemonic (const char *str, char *c, int action)
int iupStrFindMnemonic (const char *str)
int iupStrCompare (const char *str1, const char *str2, int casesensitive, int utf8)
int iupStrCompareEqual (const char *str1, const char *str2, int casesensitive, int utf8, int partial)
int iupStrCompareFind (const char *str1, const char *str2, int casesensitive, int utf8)

Detailed Description

See iup_str.h

Define Documentation

#define iup_isdigit (   _c  )     (_c>='0' && _c<='9')

Checks if the character is a digit.

#define iup_toupper (   _c  )     ((_c >= 'a' && _c <= 'z')? (_c - 'a') + 'A': _c)

Converts a character into upper case.
It will work only for character codes <128.

#define iup_tolower (   _c  )     ((_c >= 'A' && _c <= 'Z')? (_c - 'A') + 'a': _c)

Converts a character into lower case.
It will work only for character codes <128.

#define IUP_FLOAT2STR   "%.9f"

maximum float precision

#define IUP_DOUBLE2STR   "%.18f"

maximum double precision


Function Documentation

int iupStrEqual ( const char *  str1,
const char *  str2 
)

Returns a non zero value if the two strings are equal. str1 or str2 can be NULL.

int iupStrEqualNoCase ( const char *  str1,
const char *  str2 
)

Returns a non zero value if the two strings are equal but ignores case. str1 or str2 can be NULL. It will work only for character codes <128.

int iupStrEqualNoCaseNoSpace ( const char *  str1,
const char *  str2 
)

Returns a non zero value if the two strings are equal but ignores case and spaces.
str1 or str2 can be NULL.
It will work only for character codes <128.

int iupStrEqualPartial ( const char *  str1,
const char *  str2 
)

Returns a non zero value if the two strings are equal up to a number of characters defined by the strlen of the second string.
str1 or str2 can be NULL.

int iupStrEqualNoCasePartial ( const char *  str1,
const char *  str2 
)

Returns a non zero value if the two strings are equal but ignores case up to a number of characters defined by the strlen of the second string.
str1 or str2 can be NULL.
It will work only for character codes <128.

int iupStrBoolean ( const char *  str  ) 

Returns 1 if the string is "YES" or "ON".
Returns 0 otherwise (including NULL or empty).

int iupStrFalse ( const char *  str  ) 

Returns 1 if the string is "NO" or "OFF".
Returns 0 otherwise (including NULL or empty).
To be used when value can be "False" or others different than "True".

int iupStrLineCount ( const char *  str  ) 

Returns the number of lines in a string. It works for UNIX, DOS and MAC line ends.

const char* iupStrNextLine ( const char *  str,
int *  len 
)

Returns a pointer to the next line and the size of the current line. It works for UNIX, DOS and MAC line ends. The size does not includes the line end. If str is NULL it will return NULL.

const char* iupStrNextValue ( const char *  str,
int  str_len,
int *  len,
char  sep 
)

Returns a pointer to the next value and the size of the current value. The size does not includes the separator. If str is NULL it will return NULL.

int iupStrCountChar ( const char *  str,
char  c 
)

Returns the number of repetitions of the character occours in the string.

char* iupStrDup ( const char *  str  ) 

Returns a copy of the given string. If str is NULL it will return NULL.

char* iupStrDupUntil ( const char **  str,
char  c 
)

Returns a new string containing a copy of the string up to the character. The string is then incremented to after the position of the character.

void iupStrCopyN ( char *  dst_str,
int  dst_max_size,
const char *  src_str 
)

Copy the string to the buffer, but limited to the max_size of the buffer. buffer is always properly ended.

char* iupStrGetMemory ( int  size  ) 

Returns a buffer with the specified size+1.
The buffer is resused after 50 calls. It must NOT be freed. Use size=-1 to free all the internal buffers.

char* iupStrGetLargeMem ( int *  size  ) 

Returns a very large buffer to be used in unknown size string construction. Use snprintf or vsnprintf with the given size.

void iupStrLower ( char *  dstr,
const char *  sstr 
)

Converts a string into lower case. Can be used in-place.
It will work only for character codes <128.

void iupStrUpper ( char *  dstr,
const char *  sstr 
)

Converts a string into upper case. Can be used in-place.
It will work only for character codes <128.

int iupStrHasSpace ( const char *  str  ) 

Checks if the string has at least 1 space character.

int iupStrIsAscii ( const char *  str  ) 

Checks if the string has only ASCII codes.

char* iupStrReturnStrf ( const char *  format,
  ... 
)

Returns combined values in a formatted string using iupStrGetMemory. This is not supposed to be used for very large strings, just for combinations of numeric data or constant strings.

char* iupStrReturnStr ( const char *  str  ) 

Returns a string value in a string using iupStrGetMemory.

char* iupStrReturnBoolean ( int  i  ) 

Returns a boolean value (as YES or NO) in a string.

char* iupStrReturnChecked ( int  i  ) 

Returns a checked value (as ON, OFF or NOTDEF (-1)) in a string.

char* iupStrReturnInt ( int  i  ) 

Returns an int value in a string using iupStrGetMemory.

char* iupStrReturnFloat ( float  f  ) 

Returns a float value in a string using iupStrGetMemory.

char* iupStrReturnDouble ( double  d  ) 

Returns a double value in a string using iupStrGetMemory.

char* iupStrReturnRGB ( unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Returns a RGB value in a string using iupStrGetMemory.

char* iupStrReturnRGBA ( unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a 
)

Returns a RGBA value in a string using iupStrGetMemory.

char* iupStrReturnStrStr ( const char *  str1,
const char *  str2,
char  sep 
)

Returns two string values in a string using iupStrGetMemory.

char* iupStrReturnIntInt ( int  i1,
int  i2,
char  sep 
)

Returns two int values in a string using iupStrGetMemory.

int iupStrGetFormatPrecision ( const char *  format  ) 

Returns the number of decimals in a format string for floating point output.

void iupStrPrintfDoubleLocale ( char *  str,
const char *  format,
double  d,
const char *  decimal_symbol 
)

Prints a double in a string using the given decimal symbol.

int iupStrToRGB ( const char *  str,
unsigned char *  r,
unsigned char *  g,
unsigned char *  b 
)

Extract RGB components from the string. Returns 0 or 1.

int iupStrToRGBA ( const char *  str,
unsigned char *  r,
unsigned char *  g,
unsigned char *  b,
unsigned char *  a 
)

Extract RGBA components from the string. Returns 0 or 1.

int iupStrToInt ( const char *  str,
int *  i 
)

Converts the string to an int. The string must contains only the integer value. Returns a a non zero value if sucessfull.

int iupStrToIntInt ( const char *  str,
int *  i1,
int *  i2,
char  sep 
)

Converts the string to two int. The string must contains two integer values in sequence, separated by the given character (usually 'x' or ':'). Returns the number of converted values. Values not extracted are not changed.

int iupStrToFloat ( const char *  str,
float *  f 
)

Converts the string to a float. The string must contains only the real value. Returns a a non zero value if sucessfull.

int iupStrToDouble ( const char *  str,
double *  d 
)

Converts the string to a double. The string must contains only the real value. Returns a a non zero value if sucessfull.

int iupStrToDoubleLocale ( const char *  str,
double *  d,
const char *  decimal_symbol 
)

Converts the string to a double using the given decimal symbol. The string must contains only the real value. Returns a a non zero value if sucessfull. Returns 2 if a locale was set.

int iupStrToFloatFloat ( const char *  str,
float *  f1,
float *  f2,
char  sep 
)

Converts the string to two float. The string must contains two real values in sequence, separated by the given character (usually 'x' or ':'). Returns the number of converted values. Values not extracted are not changed. ATENTION: AVOID DEFINING THIS TYPE OF ATTRIBUTE VALUE.

int iupStrToDoubleDouble ( const char *  str,
double *  f1,
double *  f2,
char  sep 
)

Converts the string to two double. The string must contains two real values in sequence, separated by the given character (usually 'x' or ':'). Returns the number of converted values. Values not extracted are not changed. ATENTION: AVOID DEFINING THIS TYPE OF ATTRIBUTE VALUE.

int iupStrToStrStr ( const char *  str,
char *  str1,
char *  str2,
char  sep 
)

Extract two strings from the string. separated by the given character (usually 'x' or ':'). Returns the number of converted values. Values not extracted are set to empty strings.

char* iupStrFileGetExt ( const char *  file_name  ) 

Returns the file extension of a file name. Supports UNIX and Windows directory separators.

char* iupStrFileGetTitle ( const char *  file_name  ) 

Returns the file title of a file name. Supports UNIX and Windows directory separators.

char* iupStrFileGetPath ( const char *  file_name  ) 

Returns the file path of a file name. Supports UNIX and Windows directory separators. The returned value includes the last separator.

char* iupStrFileMakeFileName ( const char *  path,
const char *  title 
)

Concat path and title addind '/' between if path does not have it.

void iupStrFileNameSplit ( const char *  filename,
char *  path,
char *  title 
)

Split the filename in path and title using pre-allocated strings.

int iupStrReplace ( char *  str,
char  src,
char  dst 
)

Replace a character in a string. Returns the number of occurrences.

void iupStrToUnix ( char *  str  ) 

Convert line ends to UNIX format in-place (one
per line).

void iupStrToMac ( char *  str  ) 

Convert line ends to MAC format in-place (one per line).

char* iupStrToDos ( const char *  str  ) 

Convert line ends to DOS/Windows format (the sequence
per line). If returned pointer different the input, it must be freed.

char* iupStrConvertToC ( const char *  str  ) 

Convert string to C format. Process
, and . If returned pointer different the input, it must be freed.

void iupStrRemove ( char *  value,
int  start,
int  end,
int  dir,
int  utf8 
)

Remove the interval from the string. Done in-place.

char* iupStrInsert ( const char *  value,
const char *  insert_value,
int  start,
int  end,
int  utf8 
)

Remove the interval from the string and insert the new string at the start.

char* iupStrProcessMnemonic ( const char *  str,
char *  c,
int  action 
)

Process the mnemonic in the string. If not found returns str. If found returns a new string. Action can be:

  • 1: replace & by c
  • -1: remove & and return in c
  • 0: remove &
int iupStrFindMnemonic ( const char *  str  ) 

Returns the Mnemonic if found. Zero otherwise.

int iupStrCompare ( const char *  str1,
const char *  str2,
int  casesensitive,
int  utf8 
)

Compare two strings using strcmp semantics, but using the "Alphanum Algorithm" (A1 A2 A11 A30 ...).
This means that numbers and text are sorted separately.
Also natural alphabetic order is used: 123...aA...bBcC...
Sorting and case insensitive will work only for Latin-1 characters, even when using utf8=1.

int iupStrCompareEqual ( const char *  str1,
const char *  str2,
int  casesensitive,
int  utf8,
int  partial 
)

Returns a non zero value if the two strings are equal.
If partial=1 the compare up to a number of characters defined by the strlen of the second string.
Case insensitive will work only for Latin-1 characters, even when using utf8=1.

int iupStrCompareFind ( const char *  str1,
const char *  str2,
int  casesensitive,
int  utf8 
)

Returns a non zero value if the second string is found inside the first string.
Uses iupStrCompareEqual.