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. */
9 /* For Windows builds, the "tchar" type will be 2 bytes and will be equivalent
10 * to "wchar_t" and "utf16lechar". All indicate one code unit of a UTF16-LE
12 typedef wchar_t tchar;
13 # define TCHAR_IS_UTF16LE 1
14 # define _T(text) L##text
15 # define T(text) _T(text) /* Make a string literal into a wide string */
16 # define TS "ls" /* Format a string of "tchar" */
17 # define TC "lc" /* Format a "tchar" */
19 /* For Windows builds, the following definitions replace the "tchar" functions
20 * with the "wide-character" functions. */
21 # define tmemchr wmemchr
22 # define tmemcpy wmemcpy
23 # define tmemmove wmemmove
24 # define tmempcpy wmempcpy
25 # define tstrcat wcscat
26 # define tstrcpy wcscpy
27 # define tprintf wprintf
28 # define tsprintf swprintf
29 # define tfprintf fwprintf
30 # define tvfprintf vfwprintf
31 # define istalpha(c) iswalpha((wchar_t)(c))
32 # define istspace(c) iswspace((wchar_t)(c))
33 # define totlower(c) towlower((wchar_t)(c))
34 # define tstrcmp wcscmp
35 # define tstrncmp wcsncmp
36 # define tstrchr wcschr
37 # define tstrpbrk wcspbrk
38 # define tstrrchr wcsrchr
39 # define tstrlen wcslen
40 # define tmemcmp wmemcmp
41 # define tstrcasecmp _wcsicmp
42 # define tstrftime wcsftime
43 # define tputchar putwchar
46 # define tfputs fputws
47 # define tfopen _wfopen
49 # define tstat _wstati64
50 # define tstrtol wcstol
51 # define tstrtod wcstod
52 # define tstrtoul wcstoul
53 # define tunlink _wunlink
54 # define tstrerror _wcserror
55 # define taccess _waccess
56 # define tstrdup wcsdup
57 # define ttempnam _wtempnam
58 # define tgetenv _wgetenv
59 /* The following "tchar" functions do not have exact wide-character equivalents
60 * on Windows so require parameter rearrangement or redirection to a replacement
61 * function defined ourselves. */
62 # define TSTRDUP WCSDUP
63 # define tmkdir(path, mode) _wmkdir(path)
64 # define tstrerror_r win32_strerror_r_replacement
65 # define trename win32_rename_replacement
66 # define tglob win32_wglob
68 /* For non-Windows builds, the "tchar" type will be one byte and will specify a
69 * string in the locale-dependent multibyte encoding. However, only UTF-8 is
70 * well supported in this library. */
72 # define TCHAR_IS_UTF16LE 0
73 # define T(text) text /* In this case, strings of "tchar" are simply strings of
75 # define TS "s" /* Similarly, a string of "tchar" is printed just as a
77 # define TC "c" /* Print a single character */
78 /* For non-Windows builds, replace the "tchar" functions with the regular old
79 * string functions. */
80 # define tmemchr memchr
81 # define tmemcpy memcpy
82 # define tmemmove memmove
83 # define tmempcpy mempcpy
84 # define tstrcat strcat
85 # define tstrcpy strcpy
86 # define tprintf printf
87 # define tsprintf sprintf
88 # define tfprintf fprintf
89 # define tvfprintf vfprintf
90 # define istalpha(c) isalpha((unsigned char)(c))
91 # define istspace(c) isspace((unsigned char)(c))
92 # define totlower(c) tolower((unsigned char)(c))
93 # define tstrcmp strcmp
94 # define tstrncmp strncmp
95 # define tstrchr strchr
96 # define tstrpbrk strpbrk
97 # define tstrrchr strrchr
98 # define tstrlen strlen
99 # define tmemcmp memcmp
100 # define tstrcasecmp strcasecmp
101 # define tstrftime strftime
102 # define tputchar putchar
105 # define tfputs fputs
106 # define tfopen fopen
109 # define tunlink unlink
110 # define tstrerror strerror
111 # define tstrtol strtol
112 # define tstrtod strtod
113 # define tstrtoul strtoul
114 # define tmkdir mkdir
115 # define tstrdup strdup
116 # define ttempnam tempnam
117 # define tgetenv getenv
118 # define TSTRDUP STRDUP
119 # define tstrerror_r strerror_r
120 # define trename rename
121 # define taccess access
123 #endif /* !__WIN32__ */
125 #endif /* _WIMLIB_TCHAR_H */