1 #ifndef _WIMLIB_TCHAR_H
2 #define _WIMLIB_TCHAR_H
4 /* Functions to act on "tchar" strings, which have a platform-dependent encoding
5 * and character size. */
10 * For Windows builds, the "tchar" type will be 2 bytes and will be equivalent
11 * to "wchar_t" and "utf16lechar". All indicate one coding unit of a string
12 * encoded in UTF-16LE with the additional possibility of unpaired surrogates.
14 typedef wchar_t tchar;
15 # define TCHAR_IS_UTF16LE 1
16 # define _T(text) L##text
17 # define T(text) _T(text) /* Make a string literal into a wide string */
18 # define TS "ls" /* Format a string of "tchar" */
19 # define TC "lc" /* Format a "tchar" */
21 /* For Windows builds, the following definitions replace the "tchar" functions
22 * with the "wide-character" functions. */
23 # define tmemchr wmemchr
24 # define tmemcpy wmemcpy
25 # define tmemmove wmemmove
26 # define tmempcpy wmempcpy
27 # define tstrcat wcscat
28 # define tstrcpy wcscpy
29 # define tprintf wprintf
30 # define tsprintf swprintf
31 # define tfprintf fwprintf
32 # define tvfprintf vfwprintf
33 # define tscanf swscanf
34 # define istalpha(c) iswalpha((wchar_t)(c))
35 # define istspace(c) iswspace((wchar_t)(c))
36 # define totlower(c) towlower((wchar_t)(c))
37 # define tstrcmp wcscmp
38 # define tstrncmp wcsncmp
39 # define tstrchr wcschr
40 # define tstrpbrk wcspbrk
41 # define tstrrchr wcsrchr
42 # define tstrlen wcslen
43 # define tmemcmp wmemcmp
44 # define tstrcasecmp _wcsicmp
45 # define tstrftime wcsftime
46 # define tputchar putwchar
49 # define tfputs fputws
50 # define tfopen _wfopen
52 # define tstat _wstati64
53 # define tstrtol wcstol
54 # define tstrtod wcstod
55 # define tstrtoul wcstoul
56 # define tstrtoull wcstoull
57 # define tunlink _wunlink
58 # define tstrerror _wcserror
59 # define taccess _waccess
60 # define tstrdup wcsdup
61 # define tgetenv _wgetenv
62 /* The following "tchar" functions do not have exact wide-character equivalents
63 * on Windows so require parameter rearrangement or redirection to a replacement
64 * function defined ourselves. */
65 # define TSTRDUP WCSDUP
66 # define tmkdir(path, mode) _wmkdir(path)
67 # define tstrerror_r(errnum, buf, bufsize) \
68 _wcserror_s((buf), (bufsize), (errnum))
69 # define trename win32_rename_replacement
70 # define tglob win32_wglob
73 * For non-Windows builds, the "tchar" type will be one byte and will specify a
74 * string encoded in UTF-8 with the additional possibility of surrogate
78 # define TCHAR_IS_UTF16LE 0
79 # define T(text) text /* In this case, strings of "tchar" are simply strings of
81 # define TS "s" /* Similarly, a string of "tchar" is printed just as a
83 # define TC "c" /* Print a single character */
84 /* For non-Windows builds, replace the "tchar" functions with the regular old
85 * string functions. */
86 # define tmemchr memchr
87 # define tmemcpy memcpy
88 # define tmemmove memmove
89 # define tmempcpy mempcpy
90 # define tstrcat strcat
91 # define tstrcpy strcpy
92 # define tprintf printf
93 # define tsprintf sprintf
94 # define tfprintf fprintf
95 # define tvfprintf vfprintf
96 # define tscanf sscanf
97 # define istalpha(c) isalpha((unsigned char)(c))
98 # define istspace(c) isspace((unsigned char)(c))
99 # define totlower(c) tolower((unsigned char)(c))
100 # define tstrcmp strcmp
101 # define tstrncmp strncmp
102 # define tstrchr strchr
103 # define tstrpbrk strpbrk
104 # define tstrrchr strrchr
105 # define tstrlen strlen
106 # define tmemcmp memcmp
107 # define tstrcasecmp strcasecmp
108 # define tstrftime strftime
109 # define tputchar putchar
112 # define tfputs fputs
113 # define tfopen fopen
116 # define tunlink unlink
117 # define tstrerror strerror
118 # define tstrtol strtol
119 # define tstrtod strtod
120 # define tstrtoul strtoul
121 # define tstrtoull strtoull
122 # define tmkdir mkdir
123 # define tstrdup strdup
124 # define tgetenv getenv
125 # define TSTRDUP STRDUP
126 # define tstrerror_r strerror_r
127 # define trename rename
128 # define taccess access
132 #endif /* _WIMLIB_TCHAR_H */