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