Changeset 7886 for trunk/src/kernel32/char.cpp
- Timestamp:
- Feb 12, 2002, 1:00:42 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/char.cpp
r7873 r7886 1 #include <odinwrap.h> 2 #include <os2sel.h> 3 1 /* $Id: char.cpp,v 1.3 2002-02-12 12:00:41 sandervl Exp $ */ 2 3 /* 4 * USER string functions 5 * 6 * Based on WINE code (dlls\user\lstr.c) 7 * 8 * Copyright 1993 Yngvi Sigurjonsson (yngvi@hafro.is) 9 * Copyright 1996 Alexandre Julliard 10 * Copyright 1996 Marcus Meissner 11 * 12 * 13 * Project Odin Software License can be found in LICENSE.TXT 14 * 15 */ 16 17 18 #include <ctype.h> 19 #include <stdarg.h> 20 #include <stdlib.h> 21 #include <stdio.h> 22 #include <string.h> 4 23 #include <os2win.h> 5 #include <stdlib.h> 6 #include <string.h> 7 #include <winnls.h> 8 9 #include "unicode.h" 10 #include <heapstring.h> 11 #include "handlemanager.h" 24 25 #include "winnls.h" 26 27 #include <misc.h> 28 #include <wine\unicode.h> 29 30 31 #define DBG_LOCALLOG DBG_char 32 #include "dbglocal.h" 33 34 35 36 /*********************************************************************** 37 * CharNextA (USER32.@) 38 */ 39 LPSTR WINAPI CharNextA( LPCSTR ptr ) 40 { 41 dprintf2(("CharNextA %x", ptr)); 42 if (!*ptr) return (LPSTR)ptr; 43 if (IsDBCSLeadByte( ptr[0] ) && ptr[1]) return (LPSTR)(ptr + 2); 44 return (LPSTR)(ptr + 1); 45 } 46 47 48 /*********************************************************************** 49 * CharNextExA (USER32.@) 50 */ 51 LPSTR WINAPI CharNextExA( WORD codepage, LPCSTR ptr, DWORD flags ) 52 { 53 dprintf2(("CharNextExA %d %x %x", codepage, ptr, flags)); 54 55 if (!*ptr) return (LPSTR)ptr; 56 if (IsDBCSLeadByteEx( codepage, ptr[0] ) && ptr[1]) return (LPSTR)(ptr + 2); 57 return (LPSTR)(ptr + 1); 58 } 59 60 61 /*********************************************************************** 62 * CharNextExW (USER32.@) 63 */ 64 LPWSTR WINAPI CharNextExW( WORD codepage, LPCWSTR ptr, DWORD flags ) 65 { 66 dprintf2(("CharNextExW %d %x %x", codepage, ptr, flags)); 67 /* doesn't make sense, there are no codepages for Unicode */ 68 return NULL; 69 } 70 71 72 /*********************************************************************** 73 * CharNextW (USER32.@) 74 */ 75 LPWSTR WINAPI CharNextW(LPCWSTR x) 76 { 77 dprintf2(("CharNextW %x", x)); 78 79 if (*x) x++; 80 81 return (LPWSTR)x; 82 } 83 84 85 /*********************************************************************** 86 * CharPrevA (USER32.@) 87 */ 88 LPSTR WINAPI CharPrevA( LPCSTR start, LPCSTR ptr ) 89 { 90 dprintf2(("CharPrevA %x %x", start, ptr)); 91 92 while (*start && (start < ptr)) 93 { 94 LPCSTR next = CharNextA( start ); 95 if (next >= ptr) break; 96 start = next; 97 } 98 return (LPSTR)start; 99 } 100 101 102 /*********************************************************************** 103 * CharPrevExA (USER32.@) 104 */ 105 LPSTR WINAPI CharPrevExA( WORD codepage, LPCSTR start, LPCSTR ptr, DWORD flags ) 106 { 107 dprintf2(("CharPrevExA %d %x %x %x", codepage, start, ptr, flags)); 108 109 while (*start && (start < ptr)) 110 { 111 LPCSTR next = CharNextExA( codepage, start, flags ); 112 if (next > ptr) break; 113 start = next; 114 } 115 return (LPSTR)start; 116 } 117 118 119 /*********************************************************************** 120 * CharPrevExW (USER32.@) 121 */ 122 LPWSTR WINAPI CharPrevExW( WORD codepage, LPCWSTR start, LPCWSTR ptr, DWORD flags ) 123 { 124 /* doesn't make sense, there are no codepages for Unicode */ 125 dprintf2(("CharPrevExW %d %x %x %x", codepage, start, ptr, flags)); 126 return NULL; 127 } 128 129 130 /*********************************************************************** 131 * CharPrevW (USER32.@) 132 */ 133 LPWSTR WINAPI CharPrevW(LPCWSTR start,LPCWSTR x) 134 { 135 dprintf2(("CharPrevW %x %x", start, x)); 136 137 if (x>start) return (LPWSTR)(x-1); 138 else return (LPWSTR)x; 139 } 140 12 141 13 142 /*********************************************************************** … … 41 170 42 171 172 /*********************************************************************** 173 * CharToOemBuffW (USER32.@) 174 */ 175 BOOL WINAPI CharToOemBuffW( LPCWSTR s, LPSTR d, DWORD len ) 176 { 177 dprintf2(("CharToOemBuffW %x %x %d", s, d, len)); 178 179 if ( !s || !d ) return TRUE; 180 WideCharToMultiByte( CP_OEMCP, 0, s, len, d, len, NULL, NULL ); 181 return TRUE; 182 } 183 184 185 /*********************************************************************** 186 * CharToOemW (USER32.@) 187 */ 188 BOOL WINAPI CharToOemW( LPCWSTR s, LPSTR d ) 189 { 190 return CharToOemBuffW( s, d, strlenW( s ) + 1 ); 191 } 192 43 193 44 194 /*********************************************************************** … … 70 220 } 71 221 222 223 /*********************************************************************** 224 * OemToCharBuffW (USER32.@) 225 */ 226 BOOL WINAPI OemToCharBuffW( LPCSTR s, LPWSTR d, DWORD len ) 227 { 228 dprintf2(("OemToCharBuffW %x %x %d", s, d, len)); 229 230 MultiByteToWideChar( CP_OEMCP, 0, s, len, d, len ); 231 return TRUE; 232 } 233 234 235 /*********************************************************************** 236 * OemToCharW (USER32.@) 237 */ 238 BOOL WINAPI OemToCharW( LPCSTR s, LPWSTR d ) 239 { 240 return OemToCharBuffW( s, d, strlen( s ) + 1 ); 241 } 242 243 244 /*********************************************************************** 245 * CharLowerA (USER32.@) 246 * FIXME: handle current locale 247 */ 248 LPSTR WINAPI CharLowerA(LPSTR x) 249 { 250 LPSTR s; 251 252 dprintf2(("CharLowerA %x", x)); 253 254 if (HIWORD(x)) 255 { 256 s=x; 257 while (*s) 258 { 259 *s=tolower(*s); 260 s++; 261 } 262 return x; 263 } 264 else return (LPSTR)tolower((char)(int)x); 265 } 266 267 268 /*********************************************************************** 269 * CharUpperA (USER32.@) 270 * FIXME: handle current locale 271 */ 272 LPSTR WINAPI CharUpperA(LPSTR x) 273 { 274 dprintf2(("CharUpperA %x", x)); 275 276 if (HIWORD(x)) 277 { 278 LPSTR s = x; 279 while (*s) 280 { 281 *s=toupper(*s); 282 s++; 283 } 284 return x; 285 } 286 return (LPSTR)toupper((char)(int)x); 287 } 288 289 290 /*********************************************************************** 291 * CharLowerW (USER32.@) 292 */ 293 LPWSTR WINAPI CharLowerW(LPWSTR x) 294 { 295 dprintf2(("CharLowerW %x", x)); 296 if (HIWORD(x)) return strlwrW(x); 297 else return (LPWSTR)((UINT)tolowerW(LOWORD(x))); 298 } 299 300 301 /*********************************************************************** 302 * CharUpperW (USER32.@) 303 * FIXME: handle current locale 304 */ 305 LPWSTR WINAPI CharUpperW(LPWSTR x) 306 { 307 dprintf2(("CharUpperW %x", x)); 308 if (HIWORD(x)) return struprW(x); 309 else return (LPWSTR)((UINT)toupperW(LOWORD(x))); 310 } 311 312 313 /*********************************************************************** 314 * CharLowerBuffA (USER32.@) 315 * FIXME: handle current locale 316 */ 317 DWORD WINAPI CharLowerBuffA( LPSTR str, DWORD len ) 318 { 319 DWORD ret = len; 320 321 dprintf2(("CharLowerBuffA %x %d", str, len)); 322 323 if (!str) return 0; /* YES */ 324 for (; len; len--, str++) *str = tolower(*str); 325 return ret; 326 } 327 328 329 /*********************************************************************** 330 * CharLowerBuffW (USER32.@) 331 */ 332 DWORD WINAPI CharLowerBuffW( LPWSTR str, DWORD len ) 333 { 334 DWORD ret = len; 335 336 dprintf2(("CharLowerBuffW %x %d", str, len)); 337 338 if (!str) return 0; /* YES */ 339 for (; len; len--, str++) *str = tolowerW(*str); 340 return ret; 341 } 342 343 344 /*********************************************************************** 345 * CharUpperBuffA (USER32.@) 346 * FIXME: handle current locale 347 */ 348 DWORD WINAPI CharUpperBuffA( LPSTR str, DWORD len ) 349 { 350 DWORD ret = len; 351 352 dprintf2(("CharUpperBuffA %x %d", str, len)); 353 354 if (!str) return 0; /* YES */ 355 for (; len; len--, str++) *str = toupper(*str); 356 return ret; 357 } 358 359 360 /*********************************************************************** 361 * CharUpperBuffW (USER32.@) 362 */ 363 DWORD WINAPI CharUpperBuffW( LPWSTR str, DWORD len ) 364 { 365 DWORD ret = len; 366 367 dprintf2(("CharUpperBuffW %x %d", str, len)); 368 369 if (!str) return 0; /* YES */ 370 for (; len; len--, str++) *str = toupperW(*str); 371 return ret; 372 } 373 374 375 /*********************************************************************** 376 * IsCharLowerA (USER.436) (USER32.@) 377 * FIXME: handle current locale 378 */ 379 BOOL WINAPI IsCharLowerA(CHAR x) 380 { 381 dprintf2(("IsCharLowerA %x", x)); 382 return islower(x); 383 } 384 385 386 /*********************************************************************** 387 * IsCharLowerW (USER32.@) 388 */ 389 BOOL WINAPI IsCharLowerW(WCHAR x) 390 { 391 dprintf2(("IsCharLowerW %x", x)); 392 return get_char_typeW(x) & C1_LOWER; 393 } 394 395 396 /*********************************************************************** 397 * IsCharUpperA (USER.435) (USER32.@) 398 * FIXME: handle current locale 399 */ 400 BOOL WINAPI IsCharUpperA(CHAR x) 401 { 402 dprintf2(("IsCharUpperA %x", x)); 403 return isupper(x); 404 } 405 406 407 /*********************************************************************** 408 * IsCharUpperW (USER32.@) 409 */ 410 BOOL WINAPI IsCharUpperW(WCHAR x) 411 { 412 dprintf2(("IsCharUpperW %x", x)); 413 return get_char_typeW(x) & C1_UPPER; 414 } 415 416 417 /*********************************************************************** 418 * IsCharAlphaNumericW (USER32.@) 419 */ 420 BOOL WINAPI IsCharAlphaNumericW(WCHAR x) 421 { 422 dprintf2(("IsCharAlphaNumericW %x", x)); 423 return get_char_typeW(x) & (C1_ALPHA|C1_DIGIT|C1_LOWER|C1_UPPER); 424 } 425 426 427 /*********************************************************************** 428 * IsCharAlphaW (USER32.@) 429 */ 430 BOOL WINAPI IsCharAlphaW(WCHAR x) 431 { 432 dprintf2(("IsCharAlphaW %x", x)); 433 return get_char_typeW(x) & (C1_ALPHA|C1_LOWER|C1_UPPER); 434 } 435 //****************************************************************************** 436 //****************************************************************************** 437 BOOL WIN32API IsCharAlphaA( CHAR x) 438 { 439 WCHAR wch; 440 441 dprintf(("USER32: IsCharAlphaA %x", x)); 442 MultiByteToWideChar(CP_ACP, 0, &x, 1, &wch, 1); 443 return IsCharAlphaW(wch); 444 } 445 //****************************************************************************** 446 //****************************************************************************** 447 BOOL WIN32API IsCharAlphaNumericA( CHAR x) 448 { 449 dprintf(("USER32: IsCharAlphaNumericA %x", x)); 450 return (get_char_typeW(x) & C1_ALPHA) != 0; 451 } 452 //****************************************************************************** 453 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.