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 # define tgetenv _wgetenv
57 /* The following "tchar" functions do not have exact wide-character equivalents
58 * on Windows so require parameter rearrangement or redirection to a replacement
59 * function defined ourselves. */
60 # define TSTRDUP WCSDUP
61 # define tmkdir(path, mode) _wmkdir(path)
62 # define tstrerror_r win32_strerror_r_replacement
63 # define trename win32_rename_replacement
64 # define ttruncate win32_truncate_replacement
65 # define tglob win32_wglob
67 /* For non-Windows builds, the "tchar" type will be one byte and will specify a
68 * string in the locale-dependent multibyte encoding. However, only UTF-8 is
69 * well supported in this library. */
71 # define TCHAR_IS_UTF16LE 0
72 # define T(text) text /* In this case, strings of "tchar" are simply strings of
74 # define TS "s" /* Similarly, a string of "tchar" is printed just as a
76 # define TC "c" /* Print a single character */
77 # define WS "W" /* UTF-16LE strings must be printed using a special
78 extension implemented by wimlib itself. Note that
79 "ls" will not work here because a string of wide
80 characters on non-Windows systems is typically not
82 /* For non-Windows builds, replace the "tchar" functions with the regular old
83 * string functions. */
84 # define tmemchr memchr
85 # define tmemcpy memcpy
86 # define tmempcpy mempcpy
87 # define tstrcpy strcpy
88 # define tprintf printf
89 # define tsprintf sprintf
90 # define tfprintf fprintf
91 # define tvfprintf vfprintf
92 # define istalpha isalpha
93 # define istspace isspace
94 # define tstrcmp strcmp
95 # define tstrncmp strncmp
96 # define tstrchr strchr
97 # define tstrpbrk strpbrk
98 # define tstrrchr strrchr
99 # define tstrlen strlen
100 # define tmemcmp memcmp
101 # define tstrcasecmp strcasecmp
102 # define tstrftime strftime
103 # define tputchar putchar
106 # define tfputs fputs
107 # define tfopen fopen
110 # define tunlink unlink
111 # define tstrerror strerror
112 # define tstrtol strtol
113 # define tstrtod strtod
114 # define tstrtoul strtoul
115 # define tmkdir mkdir
116 # define tstrdup strdup
117 # define ttempnam tempnam
118 # define tgetenv getenv
119 # define TSTRDUP STRDUP
120 # define tstrerror_r strerror_r
121 # define trename rename
122 # define ttruncate truncate
123 # define taccess access
125 #endif /* !__WIN32__ */
127 #endif /* _WIMLIB_TCHAR_H */