ReactOS 0.4.15-dev-8413-gc1c91f2
text.c File Reference
#include <user32.h>
Include dependency graph for text.c:

Go to the source code of this file.

Functions

static WORD GetC1Type (WCHAR Ch)
 
LPSTR WINAPI CharLowerA (LPSTR str)
 
DWORD WINAPI CharLowerBuffA (LPSTR str, DWORD len)
 
DWORD WINAPI CharLowerBuffW (LPWSTR str, DWORD len)
 
LPWSTR WINAPI CharLowerW (LPWSTR x)
 
LPWSTR WINAPI CharPrevW (LPCWSTR start, LPCWSTR x)
 
LPSTR WINAPI CharNextA (LPCSTR ptr)
 
LPSTR WINAPI CharNextExA (WORD codepage, LPCSTR ptr, DWORD flags)
 
LPWSTR WINAPI CharNextW (LPCWSTR x)
 
LPSTR WINAPI CharPrevA (LPCSTR start, LPCSTR ptr)
 
LPSTR WINAPI CharPrevExA (WORD codepage, LPCSTR start, LPCSTR ptr, DWORD flags)
 
BOOL WINAPI CharToOemA (LPCSTR s, LPSTR d)
 
BOOL WINAPI CharToOemBuffA (LPCSTR s, LPSTR d, DWORD len)
 
BOOL WINAPI CharToOemBuffW (LPCWSTR s, LPSTR d, DWORD len)
 
BOOL WINAPI CharToOemW (LPCWSTR s, LPSTR d)
 
LPSTR WINAPI CharUpperA (LPSTR str)
 
DWORD WINAPI CharUpperBuffA (LPSTR str, DWORD len)
 
DWORD WINAPI CharUpperBuffW (LPWSTR str, DWORD len)
 
LPWSTR WINAPI CharUpperW (LPWSTR x)
 
BOOL WINAPI IsCharAlphaA (CHAR Ch)
 
BOOL WINAPI IsCharAlphaNumericA (CHAR Ch)
 
BOOL WINAPI IsCharAlphaNumericW (WCHAR Ch)
 
BOOL WINAPI IsCharAlphaW (WCHAR Ch)
 
BOOL WINAPI IsCharLowerA (CHAR Ch)
 
BOOL WINAPI IsCharLowerW (WCHAR Ch)
 
BOOL WINAPI IsCharUpperA (CHAR Ch)
 
BOOL WINAPI IsCharUpperW (WCHAR Ch)
 
BOOL WINAPI OemToCharA (LPCSTR s, LPSTR d)
 
BOOL WINAPI OemToCharBuffA (LPCSTR s, LPSTR d, DWORD len)
 
BOOL WINAPI OemToCharBuffW (LPCSTR s, LPWSTR d, DWORD len)
 
BOOL WINAPI OemToCharW (LPCSTR s, LPWSTR d)
 

Function Documentation

◆ CharLowerA()

LPSTR WINAPI CharLowerA ( LPSTR  str)

Definition at line 28 of file text.c.

29{
30 if (!HIWORD(str))
31 {
32 char ch = LOWORD(str);
33 CharLowerBuffA( &ch, 1 );
34 return (LPSTR)(UINT_PTR)(BYTE)ch;
35 }
36
38 {
40 }
42 {
44 _SEH2_YIELD(return NULL);
45 }
47
48 return str;
49}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define LOWORD(l)
Definition: pedump.c:82
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
const WCHAR * str
#define HIWORD(l)
Definition: typedefs.h:247
DWORD WINAPI CharLowerBuffA(LPSTR str, DWORD len)
Definition: text.c:56
char * LPSTR
Definition: xmlstorage.h:182
unsigned char BYTE
Definition: xxhash.c:193

◆ CharLowerBuffA()

DWORD WINAPI CharLowerBuffA ( LPSTR  str,
DWORD  len 
)

Definition at line 56 of file text.c.

57{
58 DWORD lenW;
59 WCHAR *strW;
60 if (!str) return 0; /* YES */
61
62 lenW = MultiByteToWideChar(CP_ACP, 0, str, len, NULL, 0);
63 strW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
64 if (strW) {
66 CharLowerBuffW(strW, lenW);
69 return len;
70 }
71 return 0;
72}
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
WCHAR strW[12]
Definition: clipboard.c:2029
DWORD WINAPI CharLowerBuffW(LPWSTR str, DWORD len)
Definition: text.c:79
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CharLowerA().

◆ CharLowerBuffW()

DWORD WINAPI CharLowerBuffW ( LPWSTR  str,
DWORD  len 
)

Definition at line 79 of file text.c.

80{
81 DWORD ret = len;
82 if (!str) return 0; /* YES */
83 for (; len; len--, str++) *str = towlower(*str);
84 return ret;
85}
#define towlower(c)
Definition: wctype.h:97
int ret

Referenced by CharLowerBuffA().

◆ CharLowerW()

LPWSTR WINAPI CharLowerW ( LPWSTR  x)

Definition at line 92 of file text.c.

93{
94 if (HIWORD(x)) return strlwrW(x);
95 else return (LPWSTR)((UINT_PTR)tolowerW(LOWORD(x)));
96}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define tolowerW(n)
Definition: unicode.h:50
#define strlwrW(s)
Definition: unicode.h:62
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ CharNextA()

LPSTR WINAPI CharNextA ( LPCSTR  ptr)

Definition at line 114 of file text.c.

115{
116 if (!*ptr) return (LPSTR)ptr;
117 if (IsDBCSLeadByte(ptr[0]) && ptr[1]) return (LPSTR)(ptr + 2);
118 return (LPSTR)(ptr + 1);
119}
BOOL WINAPI IsDBCSLeadByte(BYTE testchar)
Definition: locale.c:2123
static PVOID ptr
Definition: dispmode.c:27

◆ CharNextExA()

LPSTR WINAPI CharNextExA ( WORD  codepage,
LPCSTR  ptr,
DWORD  flags 
)

Definition at line 126 of file text.c.

127{
128 if (!*ptr) return (LPSTR)ptr;
129 if (IsDBCSLeadByteEx(codepage, ptr[0]) && ptr[1]) return (LPSTR)(ptr + 2);
130 return (LPSTR)(ptr + 1);
131}
BOOL WINAPI IsDBCSLeadByteEx(UINT codepage, BYTE testchar)
Definition: locale.c:2103
int codepage
Definition: win_iconv.c:156

◆ CharNextW()

LPWSTR WINAPI CharNextW ( LPCWSTR  x)

Definition at line 138 of file text.c.

139{
140 if (*x) x++;
141 return (LPWSTR)x;
142}

◆ CharPrevA()

LPSTR WINAPI CharPrevA ( LPCSTR  start,
LPCSTR  ptr 
)

Definition at line 149 of file text.c.

150{
151 if (ptr > start)
152 {
153 --ptr;
155 {
156 LPCSTR ch;
157 BOOL dbl = FALSE;
158
159 for (ch = ptr - 1; ch >= start; --ch)
160 {
161 if (!IsDBCSLeadByte(*ch))
162 break;
163
164 dbl = !dbl;
165 }
166 if (dbl) --ptr;
167 }
168 }
169 return (LPSTR)ptr;
170}
#define FALSE
Definition: types.h:117
PSERVERINFO gpsi
Definition: imm.c:18
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint start
Definition: gl.h:1545
#define SRVINFO_DBCSENABLED
Definition: ntuser.h:948
DWORD dwSRVIFlags
Definition: ntuser.h:1051
const char * LPCSTR
Definition: xmlstorage.h:183

◆ CharPrevExA()

LPSTR WINAPI CharPrevExA ( WORD  codepage,
LPCSTR  start,
LPCSTR  ptr,
DWORD  flags 
)

Definition at line 177 of file text.c.

178{
179 if (ptr > start)
180 {
181 LPCSTR ch;
182 BOOL dbl = FALSE;
183
184 --ptr;
185 for (ch = ptr - 1; ch >= start; --ch)
186 {
187 if (!IsDBCSLeadByteEx(codepage, *ch))
188 break;
189
190 dbl = !dbl;
191 }
192 if (dbl) --ptr;
193 }
194 return (LPSTR)ptr;
195}

◆ CharPrevW()

LPWSTR WINAPI CharPrevW ( LPCWSTR  start,
LPCWSTR  x 
)

Definition at line 103 of file text.c.

104{
105 if (x > start) return (LPWSTR)(x - 1);
106 else return (LPWSTR)x;
107}

◆ CharToOemA()

BOOL WINAPI CharToOemA ( LPCSTR  s,
LPSTR  d 
)

Definition at line 202 of file text.c.

203{
204 if (!s || !d) return FALSE;
205 return CharToOemBuffA(s, d, strlen(s) + 1);
206}
GLdouble s
Definition: gl.h:2039
#define d
Definition: ke_i.h:81
BOOL WINAPI CharToOemBuffA(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPSTR lpszDst, _In_ DWORD cchDstLength)

◆ CharToOemBuffA()

BOOL WINAPI CharToOemBuffA ( LPCSTR  s,
LPSTR  d,
DWORD  len 
)

Definition at line 213 of file text.c.

214{
215 WCHAR* bufW;
216
217 if ( !s || !d ) return FALSE;
218
219 bufW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
220 if (bufW) {
221 MultiByteToWideChar(CP_ACP, 0, s, len, bufW, len);
223 HeapFree(GetProcessHeap(), 0, bufW);
224 }
225 return TRUE;
226}
#define TRUE
Definition: types.h:120
#define CP_OEMCP
Definition: winnls.h:231

◆ CharToOemBuffW()

BOOL WINAPI CharToOemBuffW ( LPCWSTR  s,
LPSTR  d,
DWORD  len 
)

Definition at line 233 of file text.c.

234{
235 if (!s || !d)
236 return FALSE;
238 return TRUE;
239}

◆ CharToOemW()

BOOL WINAPI CharToOemW ( LPCWSTR  s,
LPSTR  d 
)

Definition at line 246 of file text.c.

247{
248 if ( !s || !d ) return FALSE;
249 return CharToOemBuffW(s, d, wcslen(s) + 1);
250}
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
BOOL WINAPI CharToOemBuffW(_In_ LPCWSTR lpszSrc, _Out_writes_(cchDstLength) LPSTR lpszDst, _In_ DWORD cchDstLength)

◆ CharUpperA()

LPSTR WINAPI CharUpperA ( LPSTR  str)

Definition at line 255 of file text.c.

256{
257 if (!HIWORD(str))
258 {
259 char ch = LOWORD(str);
260 CharUpperBuffA( &ch, 1 );
261 return (LPSTR)(UINT_PTR)(BYTE)ch;
262 }
263
265 {
267 }
269 {
271 _SEH2_YIELD(return NULL);
272 }
273 _SEH2_END;
274
275 return str;
276}
DWORD WINAPI CharUpperBuffA(LPSTR str, DWORD len)
Definition: text.c:283

◆ CharUpperBuffA()

DWORD WINAPI CharUpperBuffA ( LPSTR  str,
DWORD  len 
)

Definition at line 283 of file text.c.

284{
285 DWORD lenW;
286 WCHAR* strW;
287 if (!str) return 0; /* YES */
288
289 lenW = MultiByteToWideChar(CP_ACP, 0, str, len, NULL, 0);
290 strW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
291 if (strW) {
293 CharUpperBuffW(strW, lenW);
296 return len;
297 }
298 return 0;
299}
DWORD WINAPI CharUpperBuffW(LPWSTR str, DWORD len)
Definition: text.c:306

Referenced by CharUpperA().

◆ CharUpperBuffW()

DWORD WINAPI CharUpperBuffW ( LPWSTR  str,
DWORD  len 
)

Definition at line 306 of file text.c.

307{
308 DWORD ret = len;
309 if (!str) return 0; /* YES */
310 for (; len; len--, str++) *str = towupper(*str);
311 return ret;
312}
#define towupper(c)
Definition: wctype.h:99

Referenced by CharUpperBuffA().

◆ CharUpperW()

LPWSTR WINAPI CharUpperW ( LPWSTR  x)

Definition at line 319 of file text.c.

320{
321 if (HIWORD(x)) return struprW(x);
322 else return (LPWSTR)((UINT_PTR)toupperW(LOWORD(x)));
323}
#define toupperW(n)
Definition: unicode.h:51
#define struprW(s)
Definition: unicode.h:63

◆ GetC1Type()

static WORD GetC1Type ( WCHAR  Ch)
static

Definition at line 11 of file text.c.

12{
13 WORD CharType;
14
15 if (! GetStringTypeW(CT_CTYPE1, &Ch, 1, &CharType))
16 {
17 return 0;
18 }
19
20 return CharType;
21}
BOOL WINAPI GetStringTypeW(DWORD type, LPCWSTR src, INT count, LPWORD chartype)
Definition: locale.c:3094
unsigned short WORD
Definition: ntddk_ex.h:93
#define Ch(x, y, z)
Definition: sha2.c:141
#define CT_CTYPE1
Definition: winnls.h:237

Referenced by IsCharAlphaNumericW(), IsCharAlphaW(), IsCharLowerW(), and IsCharUpperW().

◆ IsCharAlphaA()

BOOL WINAPI IsCharAlphaA ( CHAR  Ch)

Definition at line 330 of file text.c.

331{
332 WCHAR WCh;
333
334 MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
335 return IsCharAlphaW(WCh);
336}
BOOL WINAPI IsCharAlphaW(WCHAR Ch)
Definition: text.c:366

◆ IsCharAlphaNumericA()

BOOL WINAPI IsCharAlphaNumericA ( CHAR  Ch)

Definition at line 343 of file text.c.

344{
345 WCHAR WCh;
346
347 MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
348 return IsCharAlphaNumericW(WCh);
349}
BOOL WINAPI IsCharAlphaNumericW(WCHAR Ch)
Definition: text.c:356

◆ IsCharAlphaNumericW()

BOOL WINAPI IsCharAlphaNumericW ( WCHAR  Ch)

Definition at line 356 of file text.c.

357{
358 return (GetC1Type(Ch) & (C1_ALPHA|C1_DIGIT)) != 0;
359}
#define C1_DIGIT
Definition: unicode.h:33
#define C1_ALPHA
Definition: unicode.h:39
static WORD GetC1Type(WCHAR Ch)
Definition: text.c:11

Referenced by IsCharAlphaNumericA().

◆ IsCharAlphaW()

BOOL WINAPI IsCharAlphaW ( WCHAR  Ch)

Definition at line 366 of file text.c.

367{
368 return (GetC1Type(Ch) & C1_ALPHA) != 0;
369}

Referenced by IsCharAlphaA().

◆ IsCharLowerA()

BOOL WINAPI IsCharLowerA ( CHAR  Ch)

Definition at line 376 of file text.c.

377{
378 WCHAR WCh;
379
380 MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
381 return IsCharLowerW(WCh);
382}
BOOL WINAPI IsCharLowerW(WCHAR Ch)
Definition: text.c:389

◆ IsCharLowerW()

BOOL WINAPI IsCharLowerW ( WCHAR  Ch)

Definition at line 389 of file text.c.

390{
391 return (GetC1Type(Ch) & C1_LOWER) != 0;
392}
#define C1_LOWER
Definition: unicode.h:32

Referenced by IsCharLowerA().

◆ IsCharUpperA()

BOOL WINAPI IsCharUpperA ( CHAR  Ch)

Definition at line 399 of file text.c.

400{
401 WCHAR WCh;
402
403 MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
404 return IsCharUpperW(WCh);
405}
BOOL WINAPI IsCharUpperW(WCHAR Ch)
Definition: text.c:412

◆ IsCharUpperW()

BOOL WINAPI IsCharUpperW ( WCHAR  Ch)

Definition at line 412 of file text.c.

413{
414 return (GetC1Type(Ch) & C1_UPPER) != 0;
415}
#define C1_UPPER
Definition: unicode.h:31

Referenced by IsCharUpperA().

◆ OemToCharA()

BOOL WINAPI OemToCharA ( LPCSTR  s,
LPSTR  d 
)

Definition at line 422 of file text.c.

423{
424 if ( !s || !d ) return FALSE;
425 return OemToCharBuffA(s, d, strlen(s) + 1);
426}
BOOL WINAPI OemToCharBuffA(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPSTR lpszDst, _In_ DWORD cchDstLength)

◆ OemToCharBuffA()

BOOL WINAPI OemToCharBuffA ( LPCSTR  s,
LPSTR  d,
DWORD  len 
)

Definition at line 431 of file text.c.

432{
433 WCHAR* bufW;
434
435 if ( !s || !d ) return FALSE;
436
437 bufW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
438 if (bufW) {
439 MultiByteToWideChar(CP_OEMCP, 0, s, len, bufW, len);
440 WideCharToMultiByte(CP_ACP, 0, bufW, len, d, len, NULL, NULL);
441 HeapFree(GetProcessHeap(), 0, bufW);
442 }
443 return TRUE;
444}

◆ OemToCharBuffW()

BOOL WINAPI OemToCharBuffW ( LPCSTR  s,
LPWSTR  d,
DWORD  len 
)

Definition at line 451 of file text.c.

452{
453 if ( !s || !d ) return FALSE;
455 return TRUE;
456}

◆ OemToCharW()

BOOL WINAPI OemToCharW ( LPCSTR  s,
LPWSTR  d 
)

Definition at line 461 of file text.c.

462{
463 if ( !s || !d ) return FALSE;
464 return OemToCharBuffW(s, d, strlen(s) + 1);
465}
BOOL WINAPI OemToCharBuffW(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPWSTR lpszDst, _In_ DWORD cchDstLength)