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