Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

Character and String utilities


Defines

#define SWIchar_isspace(x)
 Tests whether a character is a whitespace character.
#define SWIchar_iswspace(x)
 Tests whether a wide character is a whitespace character.
#define SWIchar_isdigit(x)   ((x) >= '0' && (x) <= '9')
 Tests whether a character is a digit.
#define SWIchar_iswdigit(x)   ((x) >= L'0' && (x) <= L'9')
 Tests whether a wide character is a digit.
#define SWIchar_isalpha(x)
 Tests whether a character is alphanumeric.
#define SWIchar_iswalpha(x)
 Tests whether a wide character is alphanumeric.
#define SWIchar_MAXSTRLEN   64
#define SWIswscanf   swscanf

Enumerations

enum  SWIcharResult {
  SWIchar_CONVERSION_LOSS = -6, SWIchar_BUFFER_OVERFLOW = -5, SWIchar_OUT_OF_MEMORY = -4, SWIchar_INVALID_INPUT = -3,
  SWIchar_FAIL = -2, SWIchar_ERROR = -1, SWIchar_SUCCESS = 0
}

Functions

const wchar_t * SWIcharReturnCodeToWcs (SWIcharResult rc)
*SWIPRINTF_API int SWIfprintf (FILE *file, const char *format,...)
SWIPRINTF_API int SWIfwprintf (FILE *file, const wchar_t *format,...)
SWIPRINTF_API int SWIsprintf (char *str, size_t maxlen, const char *format,...)
SWIPRINTF_API int SWIswprintf (wchar_t *wcs, size_t maxlen, const wchar_t *format,...)
SWIPRINTF_API int SWIvsprintf (char *str, size_t maxlen, const char *format, va_list args)
SWIPRINTF_API int SWIvswprintf (wchar_t *wcs, size_t maxlen, const wchar_t *format, va_list args)
SWIPRINTF_API wchar_t * SWIfgetws (wchar_t *ws, int n, FILE *stream)
*double SWIatof (const char *str)
 Convert a string to double.
float SWIatofloat (const char *str)
 Convert a string to float.
SWIcharResult SWIdtostr (double d, char *str, int len)
 Convert a double to a string.
SWIcharResult SWIdtowcs (double d, wchar_t *wstr, int len)
 Convert a double to a wide string.
double SWIwcstod (const wchar_t *wstr)
 Convert a wide string to double.
float SWIwcstof (const wchar_t *wstr)
 Convert a wide string to float.
SWIcharResult SWIwtof (const wchar_t *wstr, float *fval)
 Convert a wide string to float.
SWIcharResult SWIstrtowcs (const char *str, wchar_t *wstr, int len)
 Convert a narrow string to wide.
SWIcharResult SWIwcstostr (const wchar_t *wstr, char *str, int len)
 Convert a wide string to narrow.
SWIcharResult SWIitowcs (int i, wchar_t *wstr, int len)
 Convert a integer to a wide string.
SWIcharResult SWIwcstoi (const wchar_t *wstr, int *pi)
 Convert a integer to a wide string.
int SWIwtoi (const wchar_t *wstr)
 Convert a wide string to an integer.
int SWIwcsstrcmp (const wchar_t *w, const char *str)
 Compares a wide string to a narrow string.
int SWIisascii (const wchar_t *wstr)
 Tests that the given wchar string contains only ASCII characters, which are any character with a value less than than or equal to 0x7F.
int SWIislatin1 (const wchar_t *wstr)
 Tests that the given wchar string contains only LATIN-1 characters, which are any character with a value less than than or equal to 0xFF.
int SWIisvalid_unicode (const wchar_t *wstr)
 Tests that the given wchar string
  • does not contain high surrogates (D800 to DBFF)
  • does not contain non-characters (FFFE and FFFF)
  • the top 16-bit of 32-bit wchar are 0.

wchar_t * SWIwcstok (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)
 Find the next token in a wide string.
char * SWIstrtok (char *str, const char *delim, char **ptr)
 Find the next token in a string.
*SWIcharResult SWIwcstoutf8 (const wchar_t *src, unsigned char *dst, int maxdstlen)
 Wide to UTF-8 conversion.
SWIcharResult SWIutf8towcs (const unsigned char *src, wchar_t *dst, int maxdstlen)
 UTF-8 to wide conversion.
int SWIwcstoutf8len (const wchar_t *src)
 Returns the length of a UTF-8 string after conversion from wide.
int SWIutf8towcslen (const unsigned char *src)
 Returns the length of a wide string after conversion from UTF-8.


Define Documentation

#define SWIchar_isalpha  ) 
 

Value:

(((x) >= 'a' && (x) <= 'z') || \
    ((x) >= 'A' && (x) <= 'Z'))
Tests whether a character is alphanumeric.

#define SWIchar_isdigit  )     ((x) >= '0' && (x) <= '9')
 

Tests whether a character is a digit.

#define SWIchar_isspace  ) 
 

Value:

((x) == ' ' || (x) == '\t' || (x) == '\n' || \
                        (x) == '\r' || (x) == '\013' || (x) == '\014')
Tests whether a character is a whitespace character.

#define SWIchar_iswalpha  ) 
 

Value:

(((x) >= L'a' && (x) <= L'z') || \
    ((x) >= L'A' && (x) <= L'Z'))
Tests whether a wide character is alphanumeric.

#define SWIchar_iswdigit  )     ((x) >= L'0' && (x) <= L'9')
 

Tests whether a wide character is a digit.

#define SWIchar_iswspace  ) 
 

Value:

((x) == L' ' || (x) == L'\t' || (x) == L'\n' || \
                        (x) == L'\r' || (x) == L'\013' || (x) == L'\014')
Tests whether a wide character is a whitespace character.

#define SWIchar_MAXSTRLEN   64
 

#define SWIswscanf   swscanf
 


Enumeration Type Documentation

enum SWIcharResult
 

Enumeration values:
SWIchar_CONVERSION_LOSS  the conversion resulted in character loss
SWIchar_BUFFER_OVERFLOW  the buffer is too small
SWIchar_OUT_OF_MEMORY  malloc returns null
SWIchar_INVALID_INPUT  null, empty string, unicode when should be ascii only
SWIchar_FAIL  unable to convert
SWIchar_ERROR  general error
SWIchar_SUCCESS  success


Function Documentation

* double SWIatof const char *  str  ) 
 

Convert a string to double.

float SWIatofloat const char *  str  ) 
 

Convert a string to float.

const wchar_t* SWIcharReturnCodeToWcs SWIcharResult  rc  ) 
 

SWIcharResult SWIdtostr double  d,
char *  str,
int  len
 

Convert a double to a string.

SWIcharResult SWIdtowcs double  d,
wchar_t *  wstr,
int  len
 

Convert a double to a wide string.

SWIPRINTF_API wchar_t* SWIfgetws wchar_t *  ws,
int  n,
FILE *  stream
 

* SWIPRINTF_API int SWIfprintf FILE *  file,
const char *  format,
  ...
 

SWIPRINTF_API int SWIfwprintf FILE *  file,
const wchar_t *  format,
  ...
 

int SWIisascii const wchar_t *  wstr  ) 
 

Tests that the given wchar string contains only ASCII characters, which are any character with a value less than than or equal to 0x7F.

Parameters:
wstr The wide string to test
Returns:
non-zero if the string is all ascii

int SWIislatin1 const wchar_t *  wstr  ) 
 

Tests that the given wchar string contains only LATIN-1 characters, which are any character with a value less than than or equal to 0xFF.

Parameters:
wstr The wide string to test
Returns:
non-zero if the string is all Latin-1

int SWIisvalid_unicode const wchar_t *  wstr  ) 
 

Tests that the given wchar string

  • does not contain high surrogates (D800 to DBFF)
  • does not contain non-characters (FFFE and FFFF)
  • the top 16-bit of 32-bit wchar are 0.

Parameters:
wstr The wide string to test
Returns:
non-zero if the string is all Unicode.

SWIcharResult SWIitowcs int  i,
wchar_t *  wstr,
int  len
 

Convert a integer to a wide string.

SWIPRINTF_API int SWIsprintf char *  str,
size_t  maxlen,
const char *  format,
  ...
 

char* SWIstrtok char *  str,
const char *  delim,
char **  ptr
 

Find the next token in a string.

SWIcharResult SWIstrtowcs const char *  str,
wchar_t *  wstr,
int  len
 

Convert a narrow string to wide.

SWIPRINTF_API int SWIswprintf wchar_t *  wcs,
size_t  maxlen,
const wchar_t *  format,
  ...
 

SWIcharResult SWIutf8towcs const unsigned char *  src,
wchar_t *  dst,
int  maxdstlen
 

UTF-8 to wide conversion.

Parameters:
src The source UTF-8 string
dst The destination buffer the will hold the wide result.
maxdstlen The maximum number of character that dst should contain.
Returns:
-1 for buffer overflow, otherwise the length of the dst string.

int SWIutf8towcslen const unsigned char *  src  ) 
 

Returns the length of a wide string after conversion from UTF-8.

SWIPRINTF_API int SWIvsprintf char *  str,
size_t  maxlen,
const char *  format,
va_list  args
 

SWIPRINTF_API int SWIvswprintf wchar_t *  wcs,
size_t  maxlen,
const wchar_t *  format,
va_list  args
 

int SWIwcsstrcmp const wchar_t *  w,
const char *  str
 

Compares a wide string to a narrow string.

double SWIwcstod const wchar_t *  wstr  ) 
 

Convert a wide string to double.

float SWIwcstof const wchar_t *  wstr  ) 
 

Convert a wide string to float.

SWIcharResult SWIwcstoi const wchar_t *  wstr,
int *  pi
 

Convert a integer to a wide string.

wchar_t* SWIwcstok wchar_t *  wcs,
const wchar_t *  delim,
wchar_t **  ptr
 

Find the next token in a wide string.

SWIcharResult SWIwcstostr const wchar_t *  wstr,
char *  str,
int  len
 

Convert a wide string to narrow.

* SWIcharResult SWIwcstoutf8 const wchar_t *  src,
unsigned char *  dst,
int  maxdstlen
 

Wide to UTF-8 conversion.

Parameters:
src The source wide string
dst The destination buffer the will hold the UTF-8 result.
maxdstlen The maximum number of character that dst should contain.
Returns:
-1 for buffer overflow, otherwise the length of the dst string.

int SWIwcstoutf8len const wchar_t *  src  ) 
 

Returns the length of a UTF-8 string after conversion from wide.

SWIcharResult SWIwtof const wchar_t *  wstr,
float *  fval
 

Convert a wide string to float.

int SWIwtoi const wchar_t *  wstr  ) 
 

Convert a wide string to an integer.


Generated on Wed Jun 1 12:50:19 2005 for OpenVXI by  doxygen 1.4.2