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 WS "ls" /* Format a UTF-16LE string (same as above) */
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 tstrcpy wcscpy
24 # define tprintf wprintf
25 # define tsprintf swprintf
26 # define tfprintf fwprintf
27 # define tvfprintf vfwprintf
28 # define istalpha iswalpha
29 # define istspace iswspace
30 # define tstrcmp wcscmp
31 # define tstrchr wcschr
32 # define tstrpbrk wcspbrk
33 # define tstrrchr wcsrchr
34 # define tstrlen wcslen
35 # define tmemcmp wmemcmp
36 # define tstrcasecmp _wcsicmp
37 # define tstrftime wcsftime
38 # define tputchar putwchar
41 # define tfputs fputws
42 # define tfopen _wfopen
43 # define tstat _wstati64
44 # define tstrtol wcstol
45 # define tstrtod wcstod
46 # define tstrtoul wcstoul
47 # define tunlink _wunlink
48 # define tstrerror _wcserror
49 # define taccess _waccess
50 /* The following "tchar" functions do not have exact wide-character equivalents
51 * on Windows so require parameter rearrangement or redirection to a replacement
52 * function defined ourselves. */
53 # define TSTRDUP WSTRDUP
54 # define tmkdir(path, mode) _wmkdir(path)
55 # define tstrerror_r(errnum, buf, bufsize) _wcserror_s(buf, bufsize, errnum)
56 # define trename win32_rename_replacement
57 # define ttruncate win32_truncate_replacement
59 /* For non-Windows builds, the "tchar" type will be one byte and will specify a
60 * string in the locale-dependent multibyte encoding. However, only UTF-8 is
61 * well supported in this library. */
63 # define TCHAR_IS_UTF16LE 0
64 # define T(text) text /* In this case, strings of "tchar" are simply strings of
66 # define TS "s" /* Similarly, a string of "tchar" is printed just as a
68 # define WS "W" /* UTF-16LE strings must be printed using a special
69 extension implemented by wimlib itself. Note that
70 "ls" will not work here because a string of wide
71 characters on non-Windows systems is typically not
73 /* For non-Windows builds, replace the "tchar" functions with the regular old
74 * string functions. */
75 # define tmemchr memchr
76 # define tmemcpy memcpy
77 # define tstrcpy strcpy
78 # define tprintf printf
79 # define tsprintf sprintf
80 # define tfprintf fprintf
81 # define tvfprintf vfprintf
82 # define istalpha isalpha
83 # define istspace isspace
84 # define tstrcmp strcmp
85 # define tstrchr strchr
86 # define tstrpbrk strpbrk
87 # define tstrrchr strrchr
88 # define tstrlen strlen
89 # define tmemcmp memcmp
90 # define tstrcasecmp strcasecmp
91 # define tstrftime strftime
92 # define tputchar putchar
98 # define tunlink unlink
99 # define tstrerror strerror
100 # define tstrtol strtol
101 # define tstrtod strtod
102 # define tstrtoul strtoul
103 # define tmkdir mkdir
104 # define TSTRDUP STRDUP
105 # define tstrerror_r strerror_r
106 # define trename rename
107 # define ttruncate truncate
108 # define taccess access
109 #endif /* !__WIN32__ */
111 #endif /* _WIMLIB_TCHAR_H */