libwchar2 0.0.10
Data Structures | Macros | Typedefs | Enumerations | Functions
wchar2.h File Reference
#include <wctype.h>
#include <wchar.h>

Go to the source code of this file.

Data Structures

struct  string_ws
 Base wide string structure. More...
 
struct  _wdirent
 the contains constructs that facilitate directory traversing More...
 

Macros

#define USED_WCHAR2LIB   1
 Define this flag for other software, indicate enable libwchar2 in you project. More...
 
#define __WS(x)   __WS_(x)
 static string to wide type macro
 
#define __WSTR   wchar_t
 definition wchar_t string macro
 
#define __WSTRFREE   __attribute__((cleanup(__wsfree))) __WSTR
 auto free wchar_t string macro
 
#define __WSTR_FMT   "ls"
 print format wchar_t string macro
 
#define __WCHR_FMT   "lc"
 print format wchar_t char macro
 
#define __WCSZ(x)   ((x->sz + 1) * sizeof(wchar_t))
 determine size string_ws macro
 
#define wstring_appends(A, ...)   wstring_appends_(A,__VA_ARGS__,NULL)
 Macro to function wstring_appends_, see notes.
 
#define wreaddir_cb_opt(opt, val)   ((opt) | (1L << (val)))
 Macro to set options value to function _wreaddir_cb. More...
 
#define wstocscvt(A, B, D)
 wchar_t* type to char[] A char[] - array name B wchar_t* - source D - function return value if error More...
 
#define wstocsncvt(A, B, C, D)
 wchar_t* type to char[] with size A char[] - array name B wchar_t* - source C size_t - wchar_t* size D - function return value if error More...
 
#define wstrtocscvt(A, B, D)
 string_ws type to char[] this struct defined on top of this file A char[] - array name B string_ws* - source D - function return value if error More...
 

Typedefs

typedef unsigned long long int uintmax_t
 
typedef long long int intmax_t
 
typedef struct _wdirent wdirent_t
 the contains constructs that facilitate directory traversing
 
typedef void WDIR_t
 Main structure directory traversing, reference to void
 
typedef void(* wdir_cb) (unsigned int, access_e, long long, string_ws *, void *)
 CallBack for _wreaddir_cb. More...
 
typedef void(* split_cb) (wchar_t *, size_t, long, void *)
 CallBack for wstring_split_cb. More...
 

Enumerations

enum  access_e {
  ISERR = -1, ISUNK = 0, ISFIL = 1, ISLNK = 2,
  ISDIR = 3, ISCHR = 4, ISBLK = 5, ISSOCK = 6,
  ISFIFO = 7, ISWHT = 8, DIRNODIR = 9, DIRNOROOT = 10,
  DIRENTRYSIZE = 11
}
 enumeration for return waccess function More...
 

Functions

const char * wchar2version (void)
 Library current version.
 
wchar_t _towupper (wchar_t)
 Translate wide characters to uppercase. More...
 
wchar_t _towlower (wchar_t)
 Translate wide characters to lowercase. More...
 
wchar_t _towctrans (wchar_t, wctrans_t)
 Extensible wide-character translation. More...
 
wctype_t _wctype (const char *)
 Compute wide-character test type. More...
 
wctrans_t _wctrans (const char *)
 Compute wide-character translation type. More...
 
int _wcwidth (wchar_t)
 Number of column positions of a wide-character code. More...
 
int _wcswidth (const wchar_t *, size_t)
 Number of column positions of a wide-character string. More...
 
int _iswctype (wchar_t, wctype_t)
 Extensible wide-character test, wide-character classification. More...
 
int _iswxdigit (wchar_t)
 Test for hexadecimal digit wide character. More...
 
int _iswupper (wchar_t)
 Test for uppercase wide character. More...
 
int _iswspace (wchar_t)
 Test for whitespace wide character. More...
 
int _iswpunct (wchar_t)
 Test for punctuation or symbolic wide character. More...
 
int _iswprint (wchar_t)
 Test for printing wide character. More...
 
int _iswlower (wchar_t)
 Test for lowercase wide character. More...
 
int _iswgraph (wchar_t)
 Test for graphic wide character. More...
 
int _iswdigit (wchar_t)
 Test for decimal digit wide character. More...
 
int _iswcntrl (wchar_t)
 Test for control wide character. More...
 
int _iswblank (wchar_t)
 Test for whitespace wide character. More...
 
int _iswalpha (wchar_t)
 Test for whitespace wide character, alphabetic wide character predicate. More...
 
int _iswalnum (wchar_t)
 Test for alphanumeric wide character, alphabetic wide character predicate. More...
 
double _wcstod (const wchar_t *, wchar_t **)
 Convert wide character ASCII string to double number. More...
 
float _wcstof (const wchar_t *, wchar_t **)
 Convert wide character ASCII string to float number. More...
 
long double _wcstold (const wchar_t *, wchar_t **)
 Convert wide character ASCII string to long double number. More...
 
long int _wcstol (const wchar_t *, wchar_t **, int)
 Convert wide character ASCII string to long int number. More...
 
long long int _wcstoll (const wchar_t *, wchar_t **, int)
 Convert wide character ASCII string to long long int number. More...
 
unsigned long int _wcstoul (const wchar_t *, wchar_t **, int)
 Convert wide character ASCII string to unsigned long int number. More...
 
unsigned long long int _wcstoull (const wchar_t *, wchar_t **, int)
 Convert wide character ASCII string to unsigned long long int number. More...
 
intmax_t _wcstoimax (const wchar_t *, wchar_t **, int)
 Convert wide character ASCII string to intmax_t integer. More...
 
uintmax_t _wcstoumax (const wchar_t *, wchar_t **, int)
 Convert wide character ASCII string to uintmax_t integer. More...
 
size_t _wcstombs (char *restrict, const wchar_t *restrict, size_t)
 Minimal wide string to multibyte string converter. More...
 
size_t _wcstombs_s (char *restrict, const wchar_t *restrict, size_t)
 Minimal wide string to multibyte string converter + double size out buffer. More...
 
size_t _wcsrtombs (char *restrict, const wchar_t **restrict, size_t, mbstate_t *restrict)
 Convert a wide-character string to a character string. More...
 
size_t _wcrtomb (char *restrict, wchar_t, mbstate_t *restrict)
 Convert wide character to multibyte sequence. More...
 
size_t _mbstowcs (wchar_t *restrict, const char *restrict, size_t)
 Minimal multibyte string to wide string converter. More...
 
size_t _mbsrtowcs (wchar_t *restrict, const char **restrict, size_t, mbstate_t *restrict)
 Convert a character string to a wide-character string. More...
 
size_t _wcsnrtombs (char *restrict, const wchar_t **restrict, size_t, size_t, mbstate_t *restrict)
 Convert a wide-character string to a character string. More...
 
size_t _mbsnrtowcs (wchar_t *restrict, const char **restrict, size_t, size_t, mbstate_t *restrict)
 Convert a character string to a wide-character string. More...
 
size_t _mbrtowc (wchar_t *restrict, const char *restrict src, size_t, mbstate_t *restrict)
 Converts a narrow multibyte character to a wide character. More...
 
size_t _mbrlen (const char *restrict, size_t, mbstate_t *restrict)
 Get length of multibyte character. More...
 
int _mblen (const char *, size_t)
 Determines the size, in bytes, of the multibyte character whose first byte is pointed. More...
 
int _mbsinit (const mbstate_t *)
 Check if initial conversion state. More...
 
int _mbtowc (wchar_t *restrict, const char *restrict, size_t)
 Minimal multibyte to wide char converter. More...
 
int _wctomb (char *, wchar_t)
 Minimal wide char to multibyte converter. More...
 
int _wctob (wchar_t)
 Convert wide character to single byte. More...
 
wchar_t _btowc (int)
 Convert single byte character to wide character. More...
 
void wcprint (wchar_t *)
 wchar_t* print This function to test variably only! Instead use _vfprintf, _vfwprintf, _fprintf, _fwprintf More...
 
int wcstocscmp (const char *, wchar_t *, size_t)
 compare char* <-> wchar_t* This function quick compare only ASCII range, NOT all Unicode symbols support! size_t - wchar_t* size return - boolean
 
wchar_t * wcsregexp (wchar_t *restrict, wchar_t *restrict, int *)
 wcsregexp - Matches a regular expression More...
 
size_t u8stowcs (wchar_t *, const char *)
 Covert utf-8 char* to wchar_t* More...
 
size_t wcstou8s (char *, const wchar_t *)
 Convert wchar_t* to utf-8 char* More...
 
int u8sverify (const char *)
 Verify char* to utf-8 valid string. More...
 
wchar_t * _wcpcpy (wchar_t *, const wchar_t *)
 Copy a wide-character string returning a pointer to its end. More...
 
wchar_t * _wcpncpy (wchar_t *, const wchar_t *, size_t)
 Copy part of a wide-character string returning a pointer to its end. More...
 
wchar_t * _wcscat (wchar_t *, const wchar_t *)
 Concatenate wide-character strings. More...
 
wchar_t * _wcsncat (wchar_t *, const wchar_t *, size_t)
 Concatenate wide-character strings with size. More...
 
wchar_t * _wcsncpy (wchar_t *, const wchar_t *, size_t)
 Counted copy wide-character string. More...
 
wchar_t * _wcspbrk (const wchar_t *, const wchar_t *)
 Find wide characters in string. More...
 
wchar_t * _wcschr (const wchar_t *, wchar_t)
 Search for wide character in string. More...
 
wchar_t * _wcsrchr (const wchar_t *, wchar_t)
 Reverse search for wide character in string. More...
 
wchar_t * _wcsstr (const wchar_t *, const wchar_t *)
 Find wide-character string segment. More...
 
wchar_t * _wcstok (wchar_t *, const wchar_t *, wchar_t **)
 Tokenize wide-character string. More...
 
wchar_t * _wmemchr (const wchar_t *, wchar_t, size_t)
 Find wide character in memory. More...
 
wchar_t * _wmemcpy (wchar_t *, const wchar_t *, size_t)
 Copy wide characters in memory. More...
 
wchar_t * _wmemmove (wchar_t *, const wchar_t *, size_t)
 Copy wide characters in memory with overlapping areas. More...
 
wchar_t * _wmemset (wchar_t *, wchar_t, size_t)
 Set wide characters in memory. More...
 
size_t _wcslcat (wchar_t *, const wchar_t *, size_t)
 Concatenate wide-character strings to specified length.
 
size_t _wcslcpy (wchar_t *, const wchar_t *, size_t)
 Copy wide-character string to specified length.
 
size_t _wcslen (const wchar_t *)
 Wide-character string length. More...
 
size_t _wcsnlen (const wchar_t *, size_t)
 Wide-character string length with maximum limit. More...
 
size_t _wcsspn (const wchar_t *, const wchar_t *)
 Find initial match in wide-character string. More...
 
int _wcscasecmp (const wchar_t *, const wchar_t *)
 Case-insensitive wide character string compare. More...
 
int _wcsncasecmp (const wchar_t *, const wchar_t *, size_t)
 Case-insensitive wide character string compare with size. More...
 
int _wcscmp (const wchar_t *, const wchar_t *)
 Wide-character string compare. More...
 
int _wcsncmp (const wchar_t *, const wchar_t *, size_t)
 Wide-character string compare. More...
 
int _wmemcmp (const wchar_t *, const wchar_t *, size_t)
 Compare wide characters in memory. More...
 
int _vfprintf (FILE *restrict, const char *restrict, va_list)
 Write to stream char format variable argument list.
 
int _vsnprintf (char *restrict, size_t, const char *restrict, va_list)
 Write formatted data from variable argument list to sized buffer.
 
int _fprintf (FILE *restrict, const char *restrict,...)
 Write to stream char format variable arguments.
 
int _printf (const char *restrict fmt,...)
 Write to stdout char format variable arguments.
 
int _snprintf (char *restrict, size_t, const char *restrict,...)
 Format variable arguments list.
 
int _vfwprintf (FILE *restrict, const wchar_t *restrict, va_list)
 Write to stream wide character format variable argument list. More...
 
int _vswprintf (wchar_t *restrict, size_t, const wchar_t *restrict, va_list)
 Write formatted data from variable argument list to sized buffer. More...
 
int _fwprintf (FILE *restrict, const wchar_t *restrict,...)
 Write to stream wide character format variable arguments. More...
 
int _swprintf (wchar_t *restrict, size_t, const wchar_t *restrict,...)
 Write formatted wide character output. More...
 
int _wprintf (const wchar_t *restrict fmt,...)
 Write a formatted wide character string to 'stdout'. More...
 
int _fputws (const wchar_t *restrict, FILE *restrict)
 Write a wide character string to a file or stream. More...
 
wchar_t _fputwc (wchar_t, FILE *restrict)
 Write a wide character to a file or stream. More...
 
size_t _wcsftime (wchar_t *restrict, size_t sz, const wchar_t *restrict, const void *restrict)
 Convert date and time to a formatted wide-character string. More...
 
wchar_t * _wcsptime (const wchar_t *, const wchar_t *, void *)
 Convert a wide-character string representation of time to a time tm structure. More...
 
FILE * _wfopen (const wchar_t *, const wchar_t *)
 Open the stream for the file, takes as the first parameter the file name and the second parameter the opening mode in the form of wide characters. More...
 
FILE * _wfopen_s (const wchar_t *, size_t, const wchar_t *)
 The same as _wfopen, the size_t parameter must contain the length of the variable of the file name, or zero. More...
 
FILE * _wfopen_ws (const string_ws *, const wchar_t *)
 The same as _wfopen, the input parameter filename is passed in the string_ws structure. More...
 
FILE * _wfopen_selector (int, const void *, size_t, const void *)
 Automatic type selector for wfopen* functions. More...
 
FILE * u8wfopen (const wchar_t *, const wchar_t *)
 Open file stream, after converting the file name from wide characters to UTF-8. More...
 
int _wstat (const wchar_t *, void *)
 Functions wstat*() fill the structure with data about the file pointed to by struct stat, associated with the file name. More...
 
int _wstat_s (const wchar_t *, size_t, void *)
 The same as _wstat, the size_t parameter must contain the length of the variable of the file name, or zero. More...
 
int _wstat_ws (const string_ws *, void *)
 The same as _wstat, the input parameter filename is passed in the string_ws structure. More...
 
int _wstat_selector (int, const void *, size_t, const void *)
 Automatic type selector for wstat* functions. More...
 
int u8wstat (const wchar_t *, void *)
 Get file statistics by first converting the file name from wide characters to UTF-8. More...
 
int _wrename (const wchar_t *, const wchar_t *)
 The wrename() function changes the file name to a new one. More...
 
int _wrename_s (const wchar_t *, size_t, const wchar_t *, size_t)
 The same as _wrename, the size_t parameter must contain the length of the variable of the file name, or zero. More...
 
int _wrename_ws (const string_ws *, const string_ws *)
 The same as _wrename, the input parameter filename is passed in the string_ws structure. More...
 
int _wrename_selector (int, const void *, size_t, const void *, size_t)
 Automatic type selector for wrename* functions. More...
 
int u8wrename (const wchar_t *, const wchar_t *)
 Rename file, after converting the file name from wide characters to UTF-8. More...
 
int _wremove (const wchar_t *)
 The wremove*() function deletes a name from the file system. More...
 
int _wremove_s (const wchar_t *, size_t)
 The same as _wremove, the size_t parameter must contain the length of the variable of the file name, or zero. More...
 
int _wremove_ws (const string_ws *)
 The same as _wremove, the input parameter filename is passed in the string_ws structure. More...
 
int _wremove_selector (int, const void *, size_t)
 Automatic type selector for wremove* functions. More...
 
int u8wremove (const wchar_t *)
 Delete (remove) file or directory, after converting the file name from wide characters to UTF-8. More...
 
int _wmkdir (const wchar_t *, mode_t)
 Creates a directory or a chain of directories specified in the path. More...
 
int _wmkdir_s (const wchar_t *, size_t, mode_t)
 The same as _wmkdir, the size_t parameter must contain the length of the variable of the file name, or zero. More...
 
int _wmkdir_ws (const string_ws *, mode_t)
 The same as _wmkdir, the input parameter filename is passed in the string_ws structure. More...
 
int _wmkdir_selector (int, const void *, size_t, mode_t)
 Automatic type selector for wmkdir* functions. More...
 
int u8wmkdir (const wchar_t *, mode_t)
 Creates a directory or a chain of directories specified in the path, after converting the file name from wide characters to UTF-8. More...
 
access_e _waccess (const wchar_t *, int)
 Check permissions for a file or directory, wide char input. More...
 
access_e _waccess_s (const wchar_t *, size_t, int)
 Check permissions for a file or directory, wide char input with size.
 
access_e _waccess_ws (const string_ws *, int)
 Check permissions for a file or directory, struct string_ws input.
 
access_e _waccess_selector (int, const void *, size_t, int)
 Automatic type selector for wmkdir* functions.
 
access_e u8waccess (const wchar_t *, int)
 Check permissions for a file or directory, convert file name from wide characters to UTF-8. More...
 
wchar_t * _wbasename (const wchar_t *)
 Parse path file name, wide char input. More...
 
wchar_t * _wbasename_ws (const string_ws *)
 Parse path file name, struct string_ws input.
 
void * _wbasename_selector (int, const void *)
 Automatic type selector for wbasename* functions.
 
wchar_t * _wbaseext (const wchar_t *)
 Parse path extension, wide char input. More...
 
wchar_t * _wbaseext_ws (const string_ws *)
 Parse path extension, struct string_ws input.
 
void * _wbaseext_selector (int, const void *)
 Automatic type selector for wbaseext* functions.
 
wchar_t * _wbasedir (const wchar_t *, int)
 Parse path directory + normalize slash from path, wide char input. More...
 
wchar_t * _wbasedir_ws (const string_ws *, int)
 Parse path directory + normalize slash from path, struct string_ws input.
 
void * _wbasedir_selector (int, const void *, int)
 Automatic type selector for wbasedir* functions.
 
wchar_t * _wpathnormalize (const wchar_t *, size_t)
 Normalize slash from path, wide char input, int is string size, default 0. More...
 
wchar_t * _wpathnormalize_ws (const string_ws *)
 Normalize slash from path, struct string_ws input.
 
char * u8wpathnormalize (const wchar_t *)
 Normalize slash from path, convert file name from wide characters to UTF-8. More...
 
void wstring_free (string_ws *restrict)
 Memory free string, empty and clear struct string_ws. More...
 
size_t wstring_alloc (string_ws *restrict, size_t)
 Memory allocation string, struct string_ws->str output.
 
char * wstring_wstocs_alloc (const wchar_t *restrict)
 Converting string, wchar_t input, char allocate output. More...
 
char * wstring_swstocs_alloc (const string_ws *restrict)
 Converting string, string_ws input, char allocate output. More...
 
wchar_t * wstring_cstows_alloc (const char *restrict)
 Converting string, char input, wchar_t allocate output. More...
 
size_t wstring_cstows_ws_alloc (string_ws *restrict, const char *restrict)
 Converting string, string_ws input, length output. More...
 
size_t wstring_format (string_ws *, const wchar_t *restrict,...)
 Append string, format vargs support input, struct string_ws output. More...
 
size_t wstring_append (string_ws *, const wchar_t *restrict, size_t)
 Append string: wchar_t*, length input, struct string_ws output. More...
 
size_t wstring_appends_ (string_ws *,...)
 Append strings, only wchar_t* strings args inputs, struct string_ws output. More...
 
size_t wstring_append_cvt (string_ws *, const char *restrict, size_t)
 Append string: source type char*, length input, struct string_ws output. More...
 
size_t wstring_cstows (wchar_t [], size_t, const char *restrict, size_t)
 Converting string, char input, wchar_t array output, to allocate buffer write. More...
 
size_t wstring_wstocs (char [], size_t, const wchar_t *restrict, size_t)
 Converting string, wchar_t input, char array output, to allocate buffer write. More...
 
size_t wstring_wstocs_ws (char [], size_t, const string_ws *restrict)
 Converting string, structure string_ws input, char array output, to allocate buffer write.
 
wchar_t * wstring_timeformat (const wchar_t *restrict, size_t, const wchar_t *restrict, const wchar_t *restrict)
 Converting time format string to string, wchar_t and size_t input. More...
 
wchar_t * wstring_timeformat_ws (const string_ws *restrict, const wchar_t *restrict, const wchar_t *restrict)
 Converting time format string to string, string_ws input. More...
 
long wstring_split_cb (const string_ws *, wchar_t, split_cb, void *)
 Split string_ws string, from wchar_t characters and call split_cb to result data. More...
 
int wstring_isempty (const wchar_t *restrict s, int)
 Check wchar_t input string is empty, bool return. More...
 
string_ws wstring_trunc (const wchar_t *ws, int)
 Truncation string, wchar_t input, struct string_ws return.
 
size_t wstring_trunc_alloc (string_ws *restrict, const wchar_t *, int)
 Truncation string, wchar_t input, return pointer to struct string_ws and length.
 
int _wclosedir (WDIR_t *)
 Closes the directory stream. More...
 
WDIR_t_wopendir (const wchar_t *)
 Opens a directory stream and returns a pointer to the stream. The stream is set to the first entry in the directory. More...
 
wdirent_t_wreaddir (WDIR_t *)
 Reads the directory stream. More...
 
int _wreaddir_r (WDIR_t *, wdirent_t *, wdirent_t **)
 Reads the directory stream extended. More...
 
int _wreaddir_cb (wchar_t *, long, wdir_cb, void *)
 Reads the directory stream callBack. More...
 
void _wrewinddir (WDIR_t *)
 Sets the beginning in the directory stream. More...
 
void _wseekdir (WDIR_t *, long int)
 Sets the position in the directory stream. More...
 
long int _wtelldir (WDIR_t *)
 Returns the current position of the directory stream. More...
 
int wmkstemp (wchar_t *)
 Create a unique file name based on template, actually creates the file and returns its file descriptor. The name of the created file is stored in template. More...
 

Data Structure Documentation

◆ string_ws

struct string_ws

Base wide string structure.

Data Fields
wchar_t * str wide string pointer
size_t sz size wide string

◆ _wdirent

struct _wdirent

the contains constructs that facilitate directory traversing

Data Fields
unsigned int d_ino Inode number.
wchar_t d_name[256] Null-terminated filename.
long int d_off Offset.
unsigned short d_reclen Length of this record.
unsigned char d_type Type of file.

Macro Definition Documentation

◆ USED_WCHAR2LIB

#define USED_WCHAR2LIB   1

Define this flag for other software, indicate enable libwchar2 in you project.

flag indicate enable libwchar2

◆ wreaddir_cb_opt

#define wreaddir_cb_opt (   opt,
  val 
)    ((opt) | (1L << (val)))

Macro to set options value to function _wreaddir_cb.

Parameters
opt- long int options variable
val- option value, valid DIRENTRYSIZE, DIRNOROOT, DIRNODIR

Support: ALL

◆ wstocscvt

#define wstocscvt (   A,
  B,
 
)
Value:
size_t __WEV(sz,__LINE__); errno = 0; \
if (!(__WEV(sz,__LINE__) = _wcsrtombs(NULL, &(const wchar_t*){B}, 0, 0))) { \
errno = EILSEQ; return D; \
} \
char __WEV(A,__LINE__)[(__WEV(sz,__LINE__) + 1)], * A = (char*)&__WEV(A,__LINE__); \
if ((__WEV(sz,__LINE__) = _wcsrtombs(__WEV(A,__LINE__), &(const wchar_t*){B}, (__WEV(sz,__LINE__) + 1), 0))) { \
__WEV(A,__LINE__)[(__WEV(sz,__LINE__))] = '\0'; \
}
size_t _wcsrtombs(char *restrict, const wchar_t **restrict, size_t, mbstate_t *restrict)
Convert a wide-character string to a character string.

wchar_t* type to char[] A char[] - array name B wchar_t* - source D - function return value if error

Other non standart macro

◆ wstocsncvt

#define wstocsncvt (   A,
  B,
  C,
 
)
Value:
char __WEV(A,__LINE__)[(C + 1 * sizeof(wchar_t))], * A = (char*)&__WEV(A,__LINE__); errno = 0; \
if (!((C) = _wcsrtombs(__WEV(A,__LINE__), &(const wchar_t*){B}, (C * 2 + 1), 0))) { \
errno = EILSEQ; return D; \
} \
__WEV(A,__LINE__)[(C)] = '\0'
size_t _wcsrtombs(char *restrict, const wchar_t **restrict, size_t, mbstate_t *restrict)
Convert a wide-character string to a character string.

wchar_t* type to char[] with size A char[] - array name B wchar_t* - source C size_t - wchar_t* size D - function return value if error

◆ wstrtocscvt

#define wstrtocscvt (   A,
  B,
 
)
Value:
size_t __WEV(sz,__LINE__); errno = 0; \
char __WEV(A,__LINE__)[(B->sz + 1 * sizeof(wchar_t))], * A = (char*)&__WEV(A,__LINE__); \
if (!(__WEV(sz,__LINE__) = _wcsrtombs(__WEV(A,__LINE__), &(const wchar_t*){B->str}, (B->sz * 2 + 1), 0))) { \
errno = EILSEQ; return D; \
} \
__WEV(A,__LINE__)[__WEV(sz,__LINE__)] = '\0'
size_t _wcsrtombs(char *restrict, const wchar_t **restrict, size_t, mbstate_t *restrict)
Convert a wide-character string to a character string.

string_ws type to char[] this struct defined on top of this file A char[] - array name B string_ws* - source D - function return value if error

Typedef Documentation

◆ split_cb

typedef void(* split_cb) (wchar_t *, size_t, long, void *)

CallBack for wstring_split_cb.

Parameters
wchar_t- splitting part from string
size_t- Length of string part
long- counter
void- user data

◆ wdir_cb

typedef void(* wdir_cb) (unsigned int, access_e, long long, string_ws *, void *)

CallBack for _wreaddir_cb.

Parameters
long- counter
access_e- type of entry, see access_e
longlong: - size of entry
string_ws- entry name (file/directory name), see string_ws
void- user data

Enumeration Type Documentation

◆ access_e

enum access_e

enumeration for return waccess function

Enumerator
ISERR 

Error check.

ISUNK 

is a Unknown

ISFIL 

is a Regular file

ISLNK 

is a Symbolic link

ISDIR 

is a Directory

ISCHR 

is a character device

ISBLK 

is a block device

ISSOCK 

is a UNIX domain socket

ISFIFO 

is a named pipe

ISWHT 

is a whiteout" from BSD

DIRNODIR 

options for read derrictory - no print dir

DIRNOROOT 

options for read derrictory - no print root parent `.

or..` dir

DIRENTRYSIZE 

options for read derrictory - get files size

Function Documentation

◆ _btowc()

wchar_t _btowc ( int  )

Convert single byte character to wide character.

◆ _fputwc()

wchar_t _fputwc ( wchar_t  ,
FILE *  restrict 
)

Write a wide character to a file or stream.

  • fputwc

◆ _fputws()

int _fputws ( const wchar_t *  restrict,
FILE *  restrict 
)

Write a wide character string to a file or stream.

  • fputws

◆ _fwprintf()

int _fwprintf ( FILE *  restrict,
const wchar_t *  restrict,
  ... 
)

Write to stream wide character format variable arguments.

◆ _iswalnum()

int _iswalnum ( wchar_t  )

Test for alphanumeric wide character, alphabetic wide character predicate.

◆ _iswalpha()

int _iswalpha ( wchar_t  )

Test for whitespace wide character, alphabetic wide character predicate.

◆ _iswblank()

int _iswblank ( wchar_t  )

Test for whitespace wide character.

◆ _iswcntrl()

int _iswcntrl ( wchar_t  )

Test for control wide character.

◆ _iswctype()

int _iswctype ( wchar_t  ,
wctype_t   
)

Extensible wide-character test, wide-character classification.

◆ _iswdigit()

int _iswdigit ( wchar_t  )

Test for decimal digit wide character.

◆ _iswgraph()

int _iswgraph ( wchar_t  )

Test for graphic wide character.

◆ _iswlower()

int _iswlower ( wchar_t  )

Test for lowercase wide character.

◆ _iswprint()

int _iswprint ( wchar_t  )

Test for printing wide character.

◆ _iswpunct()

int _iswpunct ( wchar_t  )

Test for punctuation or symbolic wide character.

◆ _iswspace()

int _iswspace ( wchar_t  )

Test for whitespace wide character.

◆ _iswupper()

int _iswupper ( wchar_t  )

Test for uppercase wide character.

◆ _iswxdigit()

int _iswxdigit ( wchar_t  )

Test for hexadecimal digit wide character.

◆ _mblen()

int _mblen ( const char *  ,
size_t   
)

Determines the size, in bytes, of the multibyte character whose first byte is pointed.

◆ _mbrlen()

size_t _mbrlen ( const char *  restrict,
size_t  ,
mbstate_t *  restrict 
)

Get length of multibyte character.

◆ _mbrtowc()

size_t _mbrtowc ( wchar_t *  restrict,
const char *restrict  src,
size_t  ,
mbstate_t *  restrict 
)

Converts a narrow multibyte character to a wide character.

◆ _mbsinit()

int _mbsinit ( const mbstate_t *  )

Check if initial conversion state.

◆ _mbsnrtowcs()

size_t _mbsnrtowcs ( wchar_t *  restrict,
const char **  restrict,
size_t  ,
size_t  ,
mbstate_t *  restrict 
)

Convert a character string to a wide-character string.

◆ _mbsrtowcs()

size_t _mbsrtowcs ( wchar_t *  restrict,
const char **  restrict,
size_t  ,
mbstate_t *  restrict 
)

Convert a character string to a wide-character string.

◆ _mbstowcs()

size_t _mbstowcs ( wchar_t *  restrict,
const char *  restrict,
size_t   
)

Minimal multibyte string to wide string converter.

◆ _mbtowc()

int _mbtowc ( wchar_t *  restrict,
const char *  restrict,
size_t   
)

Minimal multibyte to wide char converter.

◆ _swprintf()

int _swprintf ( wchar_t *  restrict,
size_t  ,
const wchar_t *  restrict,
  ... 
)

Write formatted wide character output.

◆ _towctrans()

wchar_t _towctrans ( wchar_t  ,
wctrans_t   
)

Extensible wide-character translation.

◆ _towlower()

wchar_t _towlower ( wchar_t  )

Translate wide characters to lowercase.

◆ _towupper()

wchar_t _towupper ( wchar_t  )

Translate wide characters to uppercase.

◆ _vfwprintf()

int _vfwprintf ( FILE *  restrict,
const wchar_t *  restrict,
va_list   
)

Write to stream wide character format variable argument list.

◆ _vswprintf()

int _vswprintf ( wchar_t *  restrict,
size_t  ,
const wchar_t *  restrict,
va_list   
)

Write formatted data from variable argument list to sized buffer.

◆ _waccess()

access_e _waccess ( const wchar_t *  ,
int   
)

Check permissions for a file or directory, wide char input.

Note
All waccess* function return extended status, see access_e enum value, if error return standart -1
Attention
function returned Non-standard enum access_e result

Example:

static const char * __access_error(access_e x)
{
return (const char *)((x == ISERR) ? "Error check" :
((x == ISFIL) ? "is a Regular file" :
((x == ISLNK) ? "is a Symbolic link" :
((x == ISDIR) ? "is a Directory" : "Unknown result"))));
}
wchar_t pathmkd[] = L"this\\path\\to\\file";
ret = waccess(pathmkd, F_OK);
printf("\n\t*(%d) waccess: [%ls] -> [%d][%s]\n", __LINE__, pathmkd, ret, __access_error(ret));

◆ _wbasedir()

wchar_t* _wbasedir ( const wchar_t *  ,
int   
)

Parse path directory + normalize slash from path, wide char input.

Note
If Success return substring of path, else return NULL
Attention
all functions _wbasedir* requires to free the returned result, use type __WSTRFREE for auto free

◆ _wbaseext()

wchar_t* _wbaseext ( const wchar_t *  )

Parse path extension, wide char input.

Note
If Success return substring of path, else return NULL

◆ _wbasename()

wchar_t* _wbasename ( const wchar_t *  )

Parse path file name, wide char input.

Note
If Success return substring of path, else return NULL

◆ _wclosedir()

int _wclosedir ( WDIR_t )

Closes the directory stream.


The wclosedir() function closes the directory stream. If the function is successfully called, the file descriptor associated with the directory is also closed. The descriptor of the directory stream opened in the past will be unavailable after this call.

Support:

IBM GNU MinGW MSVC/MSVS
? This code x This code

◆ _wcpcpy()

wchar_t* _wcpcpy ( wchar_t *  ,
const wchar_t *   
)

Copy a wide-character string returning a pointer to its end.

◆ _wcpncpy()

wchar_t* _wcpncpy ( wchar_t *  ,
const wchar_t *  ,
size_t   
)

Copy part of a wide-character string returning a pointer to its end.

◆ _wcrtomb()

size_t _wcrtomb ( char *  restrict,
wchar_t  ,
mbstate_t *  restrict 
)

Convert wide character to multibyte sequence.

◆ _wcscasecmp()

int _wcscasecmp ( const wchar_t *  ,
const wchar_t *   
)

Case-insensitive wide character string compare.

◆ _wcscat()

wchar_t* _wcscat ( wchar_t *  ,
const wchar_t *   
)

Concatenate wide-character strings.

◆ _wcschr()

wchar_t* _wcschr ( const wchar_t *  ,
wchar_t   
)

Search for wide character in string.

◆ _wcscmp()

int _wcscmp ( const wchar_t *  ,
const wchar_t *   
)

Wide-character string compare.

◆ _wcsftime()

size_t _wcsftime ( wchar_t *  restrict,
size_t  sz,
const wchar_t *  restrict,
const void *  restrict 
)

Convert date and time to a formatted wide-character string.

The original version of the strftime() function is used for the conversion. The wcsftime() function converts the results from wide characters to a multibyte string and back.

IBM GNU MinGW MSVC/MSVS
x x This code This code

Example:

time_t t;
struct tm *tmi, tms = {0};
wchar_t buffer [180] = {0};
t = time(NULL);
# if defined(_MSC_VER)
if (localtime_s(&tms, &t))
break;
tmi = &tms;
# else
// cppcheck-suppress redundantAssignment
tmi = localtime(&t);
# endif
wcsftime(buffer, 180, L"%Y-%m-%d %H:%M:%S", tmi);
printf("\n\t*(%d) wcsftime -> %ls\n", __LINE__, buffer);
wcsptime(buffer, L"%Y-%m-%d %H:%M:%S", &tms);
t = mktime(&tms);
# if defined(_MSC_VER)
{
char cbuf[256];
if (ctime_s(cbuf, sizeof(cbuf), &t))
break;
printf("\n\t*(%d) wcsptime -> %s\n", __LINE__, cbuf);
}
# else
printf("\n\t*(%d) wcsptime -> %s\n", __LINE__, ctime(&t));
# endif

◆ _wcslen()

size_t _wcslen ( const wchar_t *  )

Wide-character string length.

◆ _wcsncasecmp()

int _wcsncasecmp ( const wchar_t *  ,
const wchar_t *  ,
size_t   
)

Case-insensitive wide character string compare with size.

◆ _wcsncat()

wchar_t* _wcsncat ( wchar_t *  ,
const wchar_t *  ,
size_t   
)

Concatenate wide-character strings with size.

◆ _wcsncmp()

int _wcsncmp ( const wchar_t *  ,
const wchar_t *  ,
size_t   
)

Wide-character string compare.

Wide-character string compare

◆ _wcsncpy()

wchar_t* _wcsncpy ( wchar_t *  ,
const wchar_t *  ,
size_t   
)

Counted copy wide-character string.

◆ _wcsnlen()

size_t _wcsnlen ( const wchar_t *  ,
size_t   
)

Wide-character string length with maximum limit.

◆ _wcsnrtombs()

size_t _wcsnrtombs ( char *  restrict,
const wchar_t **  restrict,
size_t  ,
size_t  ,
mbstate_t *  restrict 
)

Convert a wide-character string to a character string.

◆ _wcspbrk()

wchar_t* _wcspbrk ( const wchar_t *  ,
const wchar_t *   
)

Find wide characters in string.

◆ _wcsptime()

wchar_t* _wcsptime ( const wchar_t *  ,
const wchar_t *  ,
void *   
)

Convert a wide-character string representation of time to a time tm structure.

The function wcsptime() is equivalent to the function strptime(). The wcsptime() function converts a wide character string into a tm structure format, according to the format specified in the parameters.

IBM GNU MinGW MSVC/MSVS
x This code This code This code

Example:

time_t t;
struct tm *tmi, tms = {0};
wchar_t buffer [180] = {0};
t = time(NULL);
# if defined(_MSC_VER)
if (localtime_s(&tms, &t))
break;
tmi = &tms;
# else
// cppcheck-suppress redundantAssignment
tmi = localtime(&t);
# endif
wcsftime(buffer, 180, L"%Y-%m-%d %H:%M:%S", tmi);
printf("\n\t*(%d) wcsftime -> %ls\n", __LINE__, buffer);
wcsptime(buffer, L"%Y-%m-%d %H:%M:%S", &tms);
t = mktime(&tms);
# if defined(_MSC_VER)
{
char cbuf[256];
if (ctime_s(cbuf, sizeof(cbuf), &t))
break;
printf("\n\t*(%d) wcsptime -> %s\n", __LINE__, cbuf);
}
# else
printf("\n\t*(%d) wcsptime -> %s\n", __LINE__, ctime(&t));
# endif

◆ _wcsrchr()

wchar_t* _wcsrchr ( const wchar_t *  ,
wchar_t   
)

Reverse search for wide character in string.

◆ _wcsrtombs()

size_t _wcsrtombs ( char *  restrict,
const wchar_t **  restrict,
size_t  ,
mbstate_t *  restrict 
)

Convert a wide-character string to a character string.

◆ _wcsspn()

size_t _wcsspn ( const wchar_t *  ,
const wchar_t *   
)

Find initial match in wide-character string.

Find initial match in wide-character string

◆ _wcsstr()

wchar_t* _wcsstr ( const wchar_t *  ,
const wchar_t *   
)

Find wide-character string segment.

◆ _wcstod()

double _wcstod ( const wchar_t *  ,
wchar_t **   
)

Convert wide character ASCII string to double number.

◆ _wcstof()

float _wcstof ( const wchar_t *  ,
wchar_t **   
)

Convert wide character ASCII string to float number.

◆ _wcstoimax()

intmax_t _wcstoimax ( const wchar_t *  ,
wchar_t **  ,
int   
)

Convert wide character ASCII string to intmax_t integer.

◆ _wcstok()

wchar_t* _wcstok ( wchar_t *  ,
const wchar_t *  ,
wchar_t **   
)

Tokenize wide-character string.

◆ _wcstol()

long int _wcstol ( const wchar_t *  ,
wchar_t **  ,
int   
)

Convert wide character ASCII string to long int number.

◆ _wcstold()

long double _wcstold ( const wchar_t *  ,
wchar_t **   
)

Convert wide character ASCII string to long double number.

◆ _wcstoll()

long long int _wcstoll ( const wchar_t *  ,
wchar_t **  ,
int   
)

Convert wide character ASCII string to long long int number.

◆ _wcstombs()

size_t _wcstombs ( char *  restrict,
const wchar_t *  restrict,
size_t   
)

Minimal wide string to multibyte string converter.

◆ _wcstombs_s()

size_t _wcstombs_s ( char *  restrict,
const wchar_t *  restrict,
size_t   
)

Minimal wide string to multibyte string converter + double size out buffer.

◆ _wcstoul()

unsigned long int _wcstoul ( const wchar_t *  ,
wchar_t **  ,
int   
)

Convert wide character ASCII string to unsigned long int number.

◆ _wcstoull()

unsigned long long int _wcstoull ( const wchar_t *  ,
wchar_t **  ,
int   
)

Convert wide character ASCII string to unsigned long long int number.

◆ _wcstoumax()

uintmax_t _wcstoumax ( const wchar_t *  ,
wchar_t **  ,
int   
)

Convert wide character ASCII string to uintmax_t integer.

◆ _wcswidth()

int _wcswidth ( const wchar_t *  ,
size_t   
)

Number of column positions of a wide-character string.

◆ _wctob()

int _wctob ( wchar_t  )

Convert wide character to single byte.

◆ _wctomb()

int _wctomb ( char *  ,
wchar_t   
)

Minimal wide char to multibyte converter.

◆ _wctrans()

wctrans_t _wctrans ( const char *  )

Compute wide-character translation type.

  • wctrans

◆ _wctype()

wctype_t _wctype ( const char *  )

Compute wide-character test type.

◆ _wcwidth()

int _wcwidth ( wchar_t  )

Number of column positions of a wide-character code.

◆ _wfopen()

FILE* _wfopen ( const wchar_t *  ,
const wchar_t *   
)

Open the stream for the file, takes as the first parameter the file name and the second parameter the opening mode in the form of wide characters.

◆ _wfopen_s()

FILE* _wfopen_s ( const wchar_t *  ,
size_t  ,
const wchar_t *   
)

The same as _wfopen, the size_t parameter must contain the length of the variable of the file name, or zero.

◆ _wfopen_selector()

FILE* _wfopen_selector ( int  ,
const void *  ,
size_t  ,
const void *   
)

Automatic type selector for wfopen* functions.

◆ _wfopen_ws()

FILE* _wfopen_ws ( const string_ws ,
const wchar_t *   
)

The same as _wfopen, the input parameter filename is passed in the string_ws structure.

◆ _wmemchr()

wchar_t* _wmemchr ( const wchar_t *  ,
wchar_t  ,
size_t   
)

Find wide character in memory.

◆ _wmemcmp()

int _wmemcmp ( const wchar_t *  ,
const wchar_t *  ,
size_t   
)

Compare wide characters in memory.

◆ _wmemcpy()

wchar_t* _wmemcpy ( wchar_t *  ,
const wchar_t *  ,
size_t   
)

Copy wide characters in memory.

◆ _wmemmove()

wchar_t* _wmemmove ( wchar_t *  ,
const wchar_t *  ,
size_t   
)

Copy wide characters in memory with overlapping areas.

◆ _wmemset()

wchar_t* _wmemset ( wchar_t *  ,
wchar_t  ,
size_t   
)

Set wide characters in memory.

◆ _wmkdir()

int _wmkdir ( const wchar_t *  ,
mode_t   
)

Creates a directory or a chain of directories specified in the path.

Note
The equivalent of using the mkdir command with the -p switch for all functions wmkdir*() If the internal flag EXIST is received while creating the directory, the function continues execution, if this is the last one from the list of created directories, it returns 0. In other cases, returns a standard response as a function of mkdir(). If the directory exists from the specified path, the function continues execution, proceeding to create the next directory.

◆ _wmkdir_s()

int _wmkdir_s ( const wchar_t *  ,
size_t  ,
mode_t   
)

The same as _wmkdir, the size_t parameter must contain the length of the variable of the file name, or zero.

◆ _wmkdir_selector()

int _wmkdir_selector ( int  ,
const void *  ,
size_t  ,
mode_t   
)

Automatic type selector for wmkdir* functions.

◆ _wmkdir_ws()

int _wmkdir_ws ( const string_ws ,
mode_t   
)

The same as _wmkdir, the input parameter filename is passed in the string_ws structure.

◆ _wopendir()

WDIR_t* _wopendir ( const wchar_t *  )

Opens a directory stream and returns a pointer to the stream. The stream is set to the first entry in the directory.

After a successful call, the file descriptor of the open directory is used only within the implementation and should not be used in the application. The function sets the close-on-exec flag for the file descriptor that points to the directory.

Support:

IBM GNU MinGW MSVC/MSVS
? This code x This code

◆ _wpathnormalize()

wchar_t* _wpathnormalize ( const wchar_t *  ,
size_t   
)

Normalize slash from path, wide char input, int is string size, default 0.

Note
If Success return modified path, else return NULL
Attention
all functions _wpathnormalize* requires to free the returned result, use type __WSTRFREE for auto free

◆ _wprintf()

int _wprintf ( const wchar_t *restrict  fmt,
  ... 
)

Write a formatted wide character string to 'stdout'.

◆ _wreaddir()

wdirent_t* _wreaddir ( WDIR_t )

Reads the directory stream.

It reads the directory stream, returns a pointer to the wdirent_t structure, which represents the next element in the catalog stream. The function returns NULL when the last record in the directory stream is reached or if an error occurred.

Support:

IBM GNU MinGW MSVC/MSVS
? This code x This code

◆ _wreaddir_cb()

int _wreaddir_cb ( wchar_t *  ,
long  ,
wdir_cb  ,
void *   
)

Reads the directory stream callBack.

Parameters
wchar_t- directory path
long- options, valid DIRENTRYSIZE, DIRNOROOT, DIRNODIR bit mask set: wreaddir_cb_opt
wdir_cb- callback function, see wdir_cb
void- user data

Support:

IBM GNU MinGW MSVC/MSVS
This code This code This code This code

Table flags compatible:

FLAGS GNU MinGW MSVC/MSVS Description
DIRENTRYSIZE x Always Always Calculate size of entry
DIRNOROOT x x x Skip root directory . and ..
DIRNODIR x x x Skip all directory

Example:

int ret;
long opt = 0L;
# if defined(_MSC_VER)
wchar_t path[] = L"..\\*";
# else
wchar_t path[] = L"../";
# endif
printf("\n\tTest _wreaddir_cb:%d\t\t->\n", __LINE__);
ret = _wreaddir_cb(path, opt, NULL, NULL);
printf("\n\t*(%d) _wreaddir_cb end -> return:[%d] error:[%d] path:[%ls] -> opt: DIRNOROOT\n", __LINE__, ret, errno, path);

Example CallBack:

static void __dir_default_cb(unsigned int ino, access_e etype, long long size, string_ws *name, void *data)
{
(void) data;
fprintf(stdout, "\t\t- ino [%ld] -> type [%d] size [%lld] -> [%ls][%u]\n",
ino, etype, size, name->str, name->sz
);
}

◆ _wreaddir_r()

int _wreaddir_r ( WDIR_t ,
wdirent_t ,
wdirent_t **   
)

Reads the directory stream extended.

The function wreaddir_r() is a reentrant version. It reads the next entry from the open catalog stream and returns it in the created call buffer pointed to by the second parameter of the function. The pointer to the returned element is placed in the third parameter of the function, if the end of the directory stream is reached, NULL is returned instead of the value.

Support:

IBM GNU MinGW MSVC/MSVS
? This code x This code

◆ _wremove()

int _wremove ( const wchar_t *  )

The wremove*() function deletes a name from the file system.

Returns
If the file was safely deleted, 0 is returned, in the event of a -1 error. On error, errno is set to: ENOENT - the file does not exist, or in EACESS - access is denied.

◆ _wremove_s()

int _wremove_s ( const wchar_t *  ,
size_t   
)

The same as _wremove, the size_t parameter must contain the length of the variable of the file name, or zero.

◆ _wremove_selector()

int _wremove_selector ( int  ,
const void *  ,
size_t   
)

Automatic type selector for wremove* functions.

◆ _wremove_ws()

int _wremove_ws ( const string_ws )

The same as _wremove, the input parameter filename is passed in the string_ws structure.

◆ _wrename()

int _wrename ( const wchar_t *  ,
const wchar_t *   
)

The wrename() function changes the file name to a new one.

The wrename*() function changes the name or location of the file, returns a standard response as a function of rename(). The new name must not be the same as the names in the directory.

Returns
The function wrename() returns 0 in case of success and a nonzero value in case of an error. On error, errno is set, indicating an error.

◆ _wrename_s()

int _wrename_s ( const wchar_t *  ,
size_t  ,
const wchar_t *  ,
size_t   
)

The same as _wrename, the size_t parameter must contain the length of the variable of the file name, or zero.

◆ _wrename_selector()

int _wrename_selector ( int  ,
const void *  ,
size_t  ,
const void *  ,
size_t   
)

Automatic type selector for wrename* functions.

◆ _wrename_ws()

int _wrename_ws ( const string_ws ,
const string_ws  
)

The same as _wrename, the input parameter filename is passed in the string_ws structure.

◆ _wrewinddir()

void _wrewinddir ( WDIR_t )

Sets the beginning in the directory stream.

The wrewinddir() function flushes the current position of the stream to the beginning of the directory.

Support:

IBM GNU MinGW MSVC/MSVS
This code This code x This code

◆ _wseekdir()

void _wseekdir ( WDIR_t ,
long  int 
)

Sets the position in the directory stream.

The _wseekdir function sets the position in the directory stream from which the next call to _wreaddir will begin. The position argument must be a value that is returned by the previously called _wtelldir function.

Support:

IBM GNU MinGW MSVC/MSVS
? This code - -

◆ _wstat()

int _wstat ( const wchar_t *  ,
void *   
)

Functions wstat*() fill the structure with data about the file pointed to by struct stat, associated with the file name.

Returns
If stat is successfully populated, 0 is returned. In case of failure, -1 is returned, and errno is set to ENOENT.
Note
The operation of the functions wstat*() is completely analogous to the function stat()

◆ _wstat_s()

int _wstat_s ( const wchar_t *  ,
size_t  ,
void *   
)

The same as _wstat, the size_t parameter must contain the length of the variable of the file name, or zero.

◆ _wstat_selector()

int _wstat_selector ( int  ,
const void *  ,
size_t  ,
const void *   
)

Automatic type selector for wstat* functions.

◆ _wstat_ws()

int _wstat_ws ( const string_ws ,
void *   
)

The same as _wstat, the input parameter filename is passed in the string_ws structure.

◆ _wtelldir()

long int _wtelldir ( WDIR_t )

Returns the current position of the directory stream.

If successful, the wtelldir() function returns the current location in the directory stream. In case of an error, -1 is returned, and the corresponding value of errno is set.

Support:

IBM GNU MinGW MSVC/MSVS
? This code - -

◆ u8stowcs()

size_t u8stowcs ( wchar_t *  ,
const char *   
)

Covert utf-8 char* to wchar_t*

Parameters
wchar_t*- output
constchar*: - input return size_t - size
Note
function u8stowcs requires to free the returned result

◆ u8sverify()

int u8sverify ( const char *  )

Verify char* to utf-8 valid string.

Parameters
constchar*: - input
int- output (bool)

◆ u8waccess()

access_e u8waccess ( const wchar_t *  ,
int   
)

Check permissions for a file or directory, convert file name from wide characters to UTF-8.

Attention
function u8waccess requires to free the returned result

◆ u8wfopen()

FILE* u8wfopen ( const wchar_t *  ,
const wchar_t *   
)

Open file stream, after converting the file name from wide characters to UTF-8.

Attention
function u8wfopen requires to free the returned result

◆ u8wmkdir()

int u8wmkdir ( const wchar_t *  ,
mode_t   
)

Creates a directory or a chain of directories specified in the path, after converting the file name from wide characters to UTF-8.

Attention
function u8wmkdir requires to free the returned result

◆ u8wpathnormalize()

char* u8wpathnormalize ( const wchar_t *  )

Normalize slash from path, convert file name from wide characters to UTF-8.

Attention
function u8wpathnormalize requires to free the returned result

◆ u8wremove()

int u8wremove ( const wchar_t *  )

Delete (remove) file or directory, after converting the file name from wide characters to UTF-8.

Attention
function u8wremove requires to free the returned result

◆ u8wrename()

int u8wrename ( const wchar_t *  ,
const wchar_t *   
)

Rename file, after converting the file name from wide characters to UTF-8.

Attention
function u8wrename requires to free the returned result

◆ u8wstat()

int u8wstat ( const wchar_t *  ,
void *   
)

Get file statistics by first converting the file name from wide characters to UTF-8.

Attention
Function u8wstat requires to free the returned result

◆ wcprint()

void wcprint ( wchar_t *  )

wchar_t* print This function to test variably only! Instead use _vfprintf, _vfwprintf, _fprintf, _fwprintf

Other non standart functions

◆ wcsregexp()

wchar_t* wcsregexp ( wchar_t *  restrict,
wchar_t *  restrict,
int *   
)

wcsregexp - Matches a regular expression

Original name: aov-rx - Angel Ortega's regular expression library Copyright (C) 2011/2012 Angel Ortega angel.nosp@m.@tri.nosp@m.ptico.nosp@m..com https://github.com/angelortega/aov-rx or http://triptico.com

Parameters
rxthe regular expression
txthe text to be matched
sizea pointer to integer where the matching length is stored

Matches the string tx for the regular expression in rx. On output, the integer pointer by size will contain the number of matched characters (with 0 meaning that no matching was possible). If the end of string mark ($) is used in the regular expression and a match is effective, the ending zero is included in the match.

Returns the address of the match.

◆ wcstou8s()

size_t wcstou8s ( char *  ,
const wchar_t *   
)

Convert wchar_t* to utf-8 char*

Parameters
char*- output
constwchar_t*: - input return size_t - size
Note
function wcstou8s requires to free the returned result

◆ wmkstemp()

int wmkstemp ( wchar_t *  )

Create a unique file name based on template, actually creates the file and returns its file descriptor. The name of the created file is stored in template.

The wmkstemp() function generates a unique temporary filename from template, creates and opens the file, and returns an open file descriptor for the file. The name of the created file is stored in template.

Returns
Is error, return -1 and set errno to EEXIST, EINVAL or EFAULT.

Example:

wchar_t mkstemplate[] = L"my-tmpfileXXXXXX";
ret = wmkstemp(mkstemplate);
printf("\n\t*(%d) wmkstemp -> [%ls] open fd -> [%d]\n", __LINE__, mkstemplate, ret);
if (ret > 0)
{
__close(ret);
wremove(mkstemplate);
}

◆ wstring_append()

size_t wstring_append ( string_ws ,
const wchar_t *  restrict,
size_t   
)

Append string: wchar_t*, length input, struct string_ws output.

Parameters
destinationstring_ws
sourceString type wchar_t*.
lengthlength of source string.
Returns
length of output produced.
Attention
function wstring_append() requires to free the returned result

Example:

sz = wstring_append(&dst, (wchar_t*)aa.str, 0);
printf("\n\t*(%d) wstring_append: [%ls][%zu] -> [%zu]\n", __LINE__, dst.str, dst.sz, sz);
wstring_free(&dst);

◆ wstring_append_cvt()

size_t wstring_append_cvt ( string_ws ,
const char *  restrict,
size_t   
)

Append string: source type char*, length input, struct string_ws output.

Parameters
destinationstring_ws
sourceString type char*.
lengthlength of source string.
Returns
length of output produced.
Attention
function wstring_append_cvt() requires to free the returned result

◆ wstring_appends_()

size_t wstring_appends_ ( string_ws ,
  ... 
)

Append strings, only wchar_t* strings args inputs, struct string_ws output.

Parameters
destinationstring_ws
argumentsStrings type wchar_t*, 126 max.
Returns
length of output produced.
Note
Do not use this function directly, first use the wstring_appends() macro, or end the last function's parameters with a value of NULL.
Attention
function wstring_appends_() requires to free the returned result

Example:

// cppcheck-suppress varFuncNullUB
sz = wstring_appends_(&dst, (wchar_t*)a.str, (wchar_t*)aaa.str, (wchar_t*)aa.str, NULL);
printf("\n\t*(%d) wstring_appends: [%ls][%zu] -> [%zu]\n", __LINE__, dst.str, dst.sz, sz);
wstring_free(&dst);

◆ wstring_cstows()

size_t wstring_cstows ( wchar_t  [],
size_t  ,
const char *  restrict,
size_t   
)

Converting string, char input, wchar_t array output, to allocate buffer write.

Example:

const char wtext[] = "write text UTF8 - просто текст";
wchar_t wout[256];
char cout[(sizeof(wout) * 2)];
# if defined(_MSC_VER)
char errstr[256] = {0};
# else
char *errstr = NULL;
# endif
(void) argc;
(void) argv;
/* Console variant set to UTF8 */
/*
setlocale(LC_ALL, ".OCP");
SetConsoleCP(CP_UTF8);
SetConsoleOutputCP(CP_UTF8);
system("chcp 65001 > nul");
*/
ExChangeUTFConsoleFont();
printf("\n\t* sizeof wchar_t [%zu]\n", sizeof(wchar_t));
/* low-level Function test */
wmemset((void*)&wout, 0, wsizeof(wout));
memset((void*)&cout, 0, sizeof(cout));
ret = wcstocscmp(c, a.str, wcslen(a.str));
printf("\n\t*(%d) wcstocscmp: [%ls][%d]\n", __LINE__, a.str, ret);
ret = wcstocscmp(cc, aa.str, wcslen(aa.str));
printf("\n\t*(%d) wcstocscmp: [%ls][%d]\n", __LINE__, aa.str, ret);
ret = wcstocscmp(c, aa.str, wcslen(aa.str));
printf("\n\t*(%d) wcstocscmp: [%s] -> [%ls][%d]\n", __LINE__, c, aa.str, ret);
ret = wstring_cstows(wout, wsizeof(wout), (const char*)wtext, 0);
printf("\n\t*(%d) wstring_cstows: [%ls][%d]\n", __LINE__, wout, ret);
ret = wstring_wstocs(cout, sizeof(cout), (const wchar_t*)wout, 0);
printf("\n\t*(%d) wstring_wstocs: [%s][%d]\n", __LINE__, cout, ret);

◆ wstring_cstows_alloc()

wchar_t* wstring_cstows_alloc ( const char *  restrict)

Converting string, char input, wchar_t allocate output.

Attention
function wstring_cstows_alloc requires to free the returned result

◆ wstring_cstows_ws_alloc()

size_t wstring_cstows_ws_alloc ( string_ws restrict,
const char *  restrict 
)

Converting string, string_ws input, length output.

Attention
function wstring_cstows_alloc requires to free the returned result

◆ wstring_format()

size_t wstring_format ( string_ws ,
const wchar_t *  restrict,
  ... 
)

Append string, format vargs support input, struct string_ws output.

Parameters
destinationstring_ws
formatString type wchar_t*.
argumentsArguments support to vargs types, 125 max.
Returns
length of output produced.
Attention
curent status: broken, if out data large 8192 byte! Now, fixing output buffer size 8192 byte for *nix version. For MinGW32 always fixing output buffer size 8192 byte. TODO: rewrite length detected for *nix

Example:

sz = wstring_format(&dst, L"%ls%ls%ls", a.str, aaa.str, aa.str);
printf("\n\t*(%d) wstring_format: [%ls][%zu] -> [%zu]\n", __LINE__, dst.str, dst.sz, sz);

◆ wstring_free()

void wstring_free ( string_ws restrict)

Memory free string, empty and clear struct string_ws.

◆ wstring_isempty()

int wstring_isempty ( const wchar_t *restrict  s,
int   
)

Check wchar_t input string is empty, bool return.

◆ wstring_split_cb()

long wstring_split_cb ( const string_ws ,
wchar_t  ,
split_cb  ,
void *   
)

Split string_ws string, from wchar_t characters and call split_cb to result data.

Returns
number of splits

◆ wstring_swstocs_alloc()

char* wstring_swstocs_alloc ( const string_ws restrict)

Converting string, string_ws input, char allocate output.

Attention
function wstring_swstocs_alloc requires to free the returned result

◆ wstring_timeformat()

wchar_t* wstring_timeformat ( const wchar_t *  restrict,
size_t  ,
const wchar_t *  restrict,
const wchar_t *  restrict 
)

Converting time format string to string, wchar_t and size_t input.

Attention
function wstring_timeformat requires to free the returned result

Example:

wchar_t *tout = NULL, tstr[] = L"2018-07-24T19:03:18Z";
if ((tout = wstring_timeformat(tstr, 0, L"%Y-%m-%dT%H:%M:%S%Ez", L"%I:%M%p")) == NULL)
break;
printf("\n\t*(%d) wstring_timeformat -> [%ls] -> [%ls]\n", __LINE__, tstr, tout);
free(tout);

◆ wstring_timeformat_ws()

wchar_t* wstring_timeformat_ws ( const string_ws restrict,
const wchar_t *  restrict,
const wchar_t *  restrict 
)

Converting time format string to string, string_ws input.

Attention
function wstring_timeformat_ws requires to free the returned result

◆ wstring_wstocs()

size_t wstring_wstocs ( char  [],
size_t  ,
const wchar_t *  restrict,
size_t   
)

Converting string, wchar_t input, char array output, to allocate buffer write.

Example:

const char wtext[] = "write text UTF8 - просто текст";
wchar_t wout[256];
char cout[(sizeof(wout) * 2)];
# if defined(_MSC_VER)
char errstr[256] = {0};
# else
char *errstr = NULL;
# endif
(void) argc;
(void) argv;
/* Console variant set to UTF8 */
/*
setlocale(LC_ALL, ".OCP");
SetConsoleCP(CP_UTF8);
SetConsoleOutputCP(CP_UTF8);
system("chcp 65001 > nul");
*/
ExChangeUTFConsoleFont();
printf("\n\t* sizeof wchar_t [%zu]\n", sizeof(wchar_t));
/* low-level Function test */
wmemset((void*)&wout, 0, wsizeof(wout));
memset((void*)&cout, 0, sizeof(cout));
ret = wcstocscmp(c, a.str, wcslen(a.str));
printf("\n\t*(%d) wcstocscmp: [%ls][%d]\n", __LINE__, a.str, ret);
ret = wcstocscmp(cc, aa.str, wcslen(aa.str));
printf("\n\t*(%d) wcstocscmp: [%ls][%d]\n", __LINE__, aa.str, ret);
ret = wcstocscmp(c, aa.str, wcslen(aa.str));
printf("\n\t*(%d) wcstocscmp: [%s] -> [%ls][%d]\n", __LINE__, c, aa.str, ret);
ret = wstring_cstows(wout, wsizeof(wout), (const char*)wtext, 0);
printf("\n\t*(%d) wstring_cstows: [%ls][%d]\n", __LINE__, wout, ret);
ret = wstring_wstocs(cout, sizeof(cout), (const wchar_t*)wout, 0);
printf("\n\t*(%d) wstring_wstocs: [%s][%d]\n", __LINE__, cout, ret);

◆ wstring_wstocs_alloc()

char* wstring_wstocs_alloc ( const wchar_t *  restrict)

Converting string, wchar_t input, char allocate output.

Attention
function wstring_wstocs_alloc requires to free the returned result