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" */
18 # define WS "ls" /* Format a UTF-16LE string (same as above) */
20 /* For Windows builds, the following definitions replace the "tchar" functions
21 * with the "wide-character" functions. */
22 # define tmemchr wmemchr
23 # define tmemcpy wmemcpy
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 /* The following "tchar" functions do not have exact wide-character equivalents
57 * on Windows so require parameter rearrangement or redirection to a replacement
58 * function defined ourselves. */
59 # define TSTRDUP WCSDUP
60 # define tmkdir(path, mode) _wmkdir(path)
61 # define tstrerror_r win32_strerror_r_replacement
62 # define trename win32_rename_replacement
63 # define ttruncate win32_truncate_replacement
64 # define tglob win32_wglob
66 /* For non-Windows builds, the "tchar" type will be one byte and will specify a
67 * string in the locale-dependent multibyte encoding. However, only UTF-8 is
68 * well supported in this library. */
70 # define TCHAR_IS_UTF16LE 0
71 # define T(text) text /* In this case, strings of "tchar" are simply strings of
73 # define TS "s" /* Similarly, a string of "tchar" is printed just as a
75 # define TC "c" /* Print a single character */
76 # define WS "W" /* UTF-16LE strings must be printed using a special
77 extension implemented by wimlib itself. Note that
78 "ls" will not work here because a string of wide
79 characters on non-Windows systems is typically not
81 /* For non-Windows builds, replace the "tchar" functions with the regular old
82 * string functions. */
83 # define tmemchr memchr
84 # define tmemcpy memcpy
85 # define tmempcpy mempcpy
86 # define tstrcpy strcpy
87 # define tprintf printf
88 # define tsprintf sprintf
89 # define tfprintf fprintf
90 # define tvfprintf vfprintf
91 # define istalpha isalpha
92 # define istspace isspace
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 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 */