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