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