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
65 /* For non-Windows builds, the "tchar" type will be one byte and will specify a
66 * string in the locale-dependent multibyte encoding. However, only UTF-8 is
67 * well supported in this library. */
69 # define TCHAR_IS_UTF16LE 0
70 # define T(text) text /* In this case, strings of "tchar" are simply strings of
72 # define TS "s" /* Similarly, a string of "tchar" is printed just as a
74 # define TC "c" /* Print a single character */
75 # define WS "W" /* UTF-16LE strings must be printed using a special
76 extension implemented by wimlib itself. Note that
77 "ls" will not work here because a string of wide
78 characters on non-Windows systems is typically not
80 /* For non-Windows builds, replace the "tchar" functions with the regular old
81 * string functions. */
82 # define tmemchr memchr
83 # define tmemcpy memcpy
84 # define tmempcpy mempcpy
85 # define tstrcpy strcpy
86 # define tprintf printf
87 # define tsprintf sprintf
88 # define tfprintf fprintf
89 # define tvfprintf vfprintf
90 # define istalpha isalpha
91 # define istspace isspace
92 # define tstrcmp strcmp
93 # define tstrncmp strncmp
94 # define tstrchr strchr
95 # define tstrpbrk strpbrk
96 # define tstrrchr strrchr
97 # define tstrlen strlen
98 # define tmemcmp memcmp
99 # define tstrcasecmp strcasecmp
100 # define tstrftime strftime
101 # define tputchar putchar
104 # define tfputs fputs
105 # define tfopen fopen
108 # define tunlink unlink
109 # define tstrerror strerror
110 # define tstrtol strtol
111 # define tstrtod strtod
112 # define tstrtoul strtoul
113 # define tmkdir mkdir
114 # define tstrdup strdup
115 # define ttempnam tempnam
116 # define TSTRDUP STRDUP
117 # define tstrerror_r strerror_r
118 # define trename rename
119 # define ttruncate truncate
120 # define taccess access
121 #endif /* !__WIN32__ */
123 #endif /* _WIMLIB_TCHAR_H */