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" */
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 tmemmove wmemmove
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 # define tgetenv _wgetenv
57 # define totlower(c) towlower((wchar_t)(c))
58 /* The following "tchar" functions do not have exact wide-character equivalents
59 * on Windows so require parameter rearrangement or redirection to a replacement
60 * function defined ourselves. */
61 # define TSTRDUP WCSDUP
62 # define tmkdir(path, mode) _wmkdir(path)
63 # define tstrerror_r win32_strerror_r_replacement
64 # define trename win32_rename_replacement
65 # define tglob win32_wglob
67 /* For non-Windows builds, the "tchar" type will be one byte and will specify a
68 * string in the locale-dependent multibyte encoding. However, only UTF-8 is
69 * well supported in this library. */
71 # define TCHAR_IS_UTF16LE 0
72 # define T(text) text /* In this case, strings of "tchar" are simply strings of
74 # define TS "s" /* Similarly, a string of "tchar" is printed just as a
76 # define TC "c" /* Print a single character */
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 tmemmove memmove
82 # define tmempcpy mempcpy
83 # define tstrcpy strcpy
84 # define tprintf printf
85 # define tsprintf sprintf
86 # define tfprintf fprintf
87 # define tvfprintf vfprintf
88 # define istalpha isalpha
89 # define istspace isspace
90 # define tstrcmp strcmp
91 # define tstrncmp strncmp
92 # define tstrchr strchr
93 # define tstrpbrk strpbrk
94 # define tstrrchr strrchr
95 # define tstrlen strlen
96 # define tmemcmp memcmp
97 # define tstrcasecmp strcasecmp
98 # define tstrftime strftime
99 # define tputchar putchar
102 # define tfputs fputs
103 # define tfopen fopen
106 # define tunlink unlink
107 # define tstrerror strerror
108 # define tstrtol strtol
109 # define tstrtod strtod
110 # define tstrtoul strtoul
111 # define tmkdir mkdir
112 # define tstrdup strdup
113 # define ttempnam tempnam
114 # define tgetenv getenv
115 # define totlower(c) tolower((unsigned char)(c))
116 # define TSTRDUP STRDUP
117 # define tstrerror_r strerror_r
118 # define trename rename
119 # define taccess access
121 #endif /* !__WIN32__ */
123 #endif /* _WIMLIB_TCHAR_H */