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 tstrcpy wcscpy
26 # define tprintf wprintf
27 # define tsprintf swprintf
28 # define tfprintf fwprintf
29 # define tvfprintf vfwprintf
30 # define istalpha iswalpha
31 # define istspace iswspace
32 # define tstrcmp wcscmp
33 # define tstrncmp wcsncmp
34 # define tstrchr wcschr
35 # define tstrpbrk wcspbrk
36 # define tstrrchr wcsrchr
37 # define tstrlen wcslen
38 # define tmemcmp wmemcmp
39 # define tstrcasecmp _wcsicmp
40 # define tstrftime wcsftime
41 # define tputchar putwchar
44 # define tfputs fputws
45 # define tfopen _wfopen
47 # define tstat _wstati64
48 # define tstrtol wcstol
49 # define tstrtod wcstod
50 # define tstrtoul wcstoul
51 # define tunlink _wunlink
52 # define tstrerror _wcserror
53 # define taccess _waccess
54 # define tstrdup wcsdup
55 # define ttempnam _wtempnam
56 # define tgetenv _wgetenv
57 # define totlower(c) towlower((wchar_t)(c))
58 /* The following "tchar" functions do not have exact wide-character equivalents
59 * on Windows so require parameter rearrangement or redirection to a replacement
60 * function defined ourselves. */
61 # define TSTRDUP WCSDUP
62 # define tmkdir(path, mode) _wmkdir(path)
63 # define tstrerror_r win32_strerror_r_replacement
64 # define trename win32_rename_replacement
65 # define ttruncate win32_truncate_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 tstrcpy strcpy
85 # define tprintf printf
86 # define tsprintf sprintf
87 # define tfprintf fprintf
88 # define tvfprintf vfprintf
89 # define istalpha isalpha
90 # define istspace isspace
91 # define tstrcmp strcmp
92 # define tstrncmp strncmp
93 # define tstrchr strchr
94 # define tstrpbrk strpbrk
95 # define tstrrchr strrchr
96 # define tstrlen strlen
97 # define tmemcmp memcmp
98 # define tstrcasecmp strcasecmp
99 # define tstrftime strftime
100 # define tputchar putchar
103 # define tfputs fputs
104 # define tfopen fopen
107 # define tunlink unlink
108 # define tstrerror strerror
109 # define tstrtol strtol
110 # define tstrtod strtod
111 # define tstrtoul strtoul
112 # define tmkdir mkdir
113 # define tstrdup strdup
114 # define ttempnam tempnam
115 # define tgetenv getenv
116 # define totlower(c) tolower((unsigned char)(c))
117 # define TSTRDUP STRDUP
118 # define tstrerror_r strerror_r
119 # define trename rename
120 # define ttruncate truncate
121 # define taccess access
123 #endif /* !__WIN32__ */
125 #endif /* _WIMLIB_TCHAR_H */