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 win32_strerror_r_replacement
68 # define trename win32_rename_replacement
69 # define tglob win32_wglob
72 * For non-Windows builds, the "tchar" type will be one byte and will specify a
73 * string encoded in UTF-8 with the additional possibility of surrogate
77 # define TCHAR_IS_UTF16LE 0
78 # define T(text) text /* In this case, strings of "tchar" are simply strings of
80 # define TS "s" /* Similarly, a string of "tchar" is printed just as a
82 # define TC "c" /* Print a single character */
83 /* For non-Windows builds, replace the "tchar" functions with the regular old
84 * string functions. */
85 # define tmemchr memchr
86 # define tmemcpy memcpy
87 # define tmemmove memmove
88 # define tmempcpy mempcpy
89 # define tstrcat strcat
90 # define tstrcpy strcpy
91 # define tprintf printf
92 # define tsprintf sprintf
93 # define tfprintf fprintf
94 # define tvfprintf vfprintf
95 # define tscanf sscanf
96 # define istalpha(c) isalpha((unsigned char)(c))
97 # define istspace(c) isspace((unsigned char)(c))
98 # define totlower(c) tolower((unsigned char)(c))
99 # define tstrcmp strcmp
100 # define tstrncmp strncmp
101 # define tstrchr strchr
102 # define tstrpbrk strpbrk
103 # define tstrrchr strrchr
104 # define tstrlen strlen
105 # define tmemcmp memcmp
106 # define tstrcasecmp strcasecmp
107 # define tstrftime strftime
108 # define tputchar putchar
111 # define tfputs fputs
112 # define tfopen fopen
115 # define tunlink unlink
116 # define tstrerror strerror
117 # define tstrtol strtol
118 # define tstrtod strtod
119 # define tstrtoul strtoul
120 # define tstrtoull strtoull
121 # define tmkdir mkdir
122 # define tstrdup strdup
123 # define tgetenv getenv
124 # define TSTRDUP STRDUP
125 # define tstrerror_r strerror_r
126 # define trename rename
127 # define taccess access
129 #endif /* !__WIN32__ */
131 #endif /* _WIMLIB_TCHAR_H */