Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

wstrings.c File Reference

#include "precomp.h"

Go to the source code of this file.

Defines

#define LATIN_CAPITAL_LETTER_A_GRAVE   (WCHAR)0xc0
#define LATIN_CAPITAL_LETTER_THORN   (WCHAR)0xde
#define LATIN_SMALL_LETTER_SHARP_S   (WCHAR)0xdf
#define LATIN_SMALL_LETTER_Y_DIAERESIS   (WCHAR)0xff
#define DIVISION_SIGN   (WCHAR)0xf7
#define MULTIPLICATION_SIGN   (WCHAR)0xd7
#define WCTOA(wch)   ((wch) & 0xff)
#define IS_UNICODE_BLK1(wch)   ((int)(wch) <= 0x00ff)

Functions

LPWSTR WINAPI CharLowerW (LPWSTR pwsz)
LPWSTR WINAPI CharUpperW (LPWSTR pwsz)
LPWSTR WINAPI CharNextW (LPCWSTR lpwCurrentChar)
LPWSTR WINAPI CharPrevW (LPCWSTR lpwStart, LPCWSTR lpwCurrentChar)
DWORD WINAPI CharLowerBuffW (LPWSTR pwsz, DWORD cwch)
DWORD WINAPI CharUpperBuffW (LPWSTR pwsz, DWORD cwch)
BOOL WINAPI IsCharLowerW (WCHAR wChar)
BOOL WINAPI IsCharUpperW (WCHAR wChar)
BOOL WINAPI IsCharAlphaNumericW (WCHAR wChar)
BOOL WINAPI IsCharAlphaW (WCHAR wChar)


Define Documentation

#define DIVISION_SIGN   (WCHAR)0xf7
 

Definition at line 23 of file wstrings.c.

#define IS_UNICODE_BLK1 wch   )     ((int)(wch) <= 0x00ff)
 

Definition at line 31 of file wstrings.c.

Referenced by CharLowerBuffW(), CharUpperBuffW(), IsCharLowerW(), and IsCharUpperW().

#define LATIN_CAPITAL_LETTER_A_GRAVE   (WCHAR)0xc0
 

Definition at line 19 of file wstrings.c.

#define LATIN_CAPITAL_LETTER_THORN   (WCHAR)0xde
 

Definition at line 20 of file wstrings.c.

#define LATIN_SMALL_LETTER_SHARP_S   (WCHAR)0xdf
 

Definition at line 21 of file wstrings.c.

#define LATIN_SMALL_LETTER_Y_DIAERESIS   (WCHAR)0xff
 

Definition at line 22 of file wstrings.c.

#define MULTIPLICATION_SIGN   (WCHAR)0xd7
 

Definition at line 24 of file wstrings.c.

#define WCTOA wch   )     ((wch) & 0xff)
 

Definition at line 30 of file wstrings.c.


Function Documentation

DWORD WINAPI CharLowerBuffW LPWSTR  pwsz,
DWORD  cwch
 

Definition at line 252 of file wstrings.c.

References DWORD, IS_UNICODE_BLK1, and IsCharUpperA().

Referenced by CharLowerBuffA(), CharLowerW(), ECInsertText(), and xxxLBInsertItem().

00255 { 00256 int cwchT; 00257 DWORD i; 00258 00259 if (cwch == 0) { 00260 return 0; 00261 } 00262 00263 cwchT = LCMapStringW(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, 00264 pwsz, cwch, pwsz, cwch); 00265 00266 if (cwchT != 0) { 00267 return cwchT; 00268 } 00269 00270 /* 00271 * LCMapString failed! The caller is not expecting failure, 00272 * CharLowerBuffW does not have a failure indicator, so we 00273 * convert the buffer to lower case as best we can. 00274 */ 00275 RIPMSG1(RIP_WARNING, "CharLowerBuffW(%ls) failed", pwsz); 00276 00277 for (i=0; i < cwch; i++) { 00278 if (IS_UNICODE_BLK1(pwsz[i]) && IsCharUpperA((char)pwsz[i])) { 00279 pwsz[i] += 'a'-'A'; 00280 } 00281 } 00282 00283 return cwch; 00284 }

LPWSTR WINAPI CharLowerW LPWSTR  pwsz  ) 
 

Definition at line 49 of file wstrings.c.

References CharLowerBuffW(), IS_PTR, and NULL.

Referenced by FindMnemChar().

00051 { 00052 /* 00053 * Early out for NULL string or '\0' 00054 */ 00055 if (pwsz == NULL) { 00056 return pwsz; 00057 } 00058 00059 if (!IS_PTR(pwsz)) { 00060 if (!LCMapStringW( 00061 LOCALE_USER_DEFAULT, 00062 LCMAP_LOWERCASE, 00063 (LPWSTR)&pwsz, 00064 1, 00065 (LPWSTR)&pwsz, 00066 1 00067 )) { 00068 /* 00069 * We don't expect LCMapString to fail! The caller is not expecting 00070 * failure, CharLowerW does not have a failure indicator, so we do 00071 * nothing. 00072 */ 00073 RIPMSG1(RIP_WARNING, "CharLowerW(%#p): LCMapString failed\n", pwsz); 00074 } 00075 00076 return pwsz; 00077 } 00078 00079 /* 00080 * pwsz is a null-terminated string 00081 */ 00082 CharLowerBuffW(pwsz, wcslen(pwsz)+1); 00083 return pwsz; 00084 }

LPWSTR WINAPI CharNextW LPCWSTR  lpwCurrentChar  ) 
 

Definition at line 154 of file wstrings.c.

Referenced by CompStrWToCharA(), and CompStrWToCharW().

00156 { 00157 WORD ctype3info; 00158 00159 if (*lpwCurrentChar) { 00160 // 00161 // Examine each code element. Skip all combining elements. 00162 // 00163 while (*(++lpwCurrentChar)) { 00164 if (!GetStringTypeW( 00165 CT_CTYPE3, 00166 lpwCurrentChar, 00167 1, 00168 &ctype3info)) { 00169 /* 00170 * GetStringTypeW failed! The caller is not expecting failure, 00171 * CharNextW does not have a failure indicator, so just return 00172 * a pointer to the character we couldn't analyze. 00173 */ 00174 RIPMSG2(RIP_WARNING, "CharNextW failed, L'\\x%.4x' at %#p", 00175 *lpwCurrentChar, lpwCurrentChar); 00176 break; 00177 } 00178 if (!((ctype3info & C3_NONSPACING) && (!(ctype3info & C3_ALPHA)))) { 00179 break; 00180 } 00181 } 00182 } 00183 00184 return (LPWSTR)lpwCurrentChar; 00185 }

LPWSTR WINAPI CharPrevW LPCWSTR  lpwStart,
LPCWSTR  lpwCurrentChar
 

Definition at line 203 of file wstrings.c.

00206 { 00207 WORD ctype3info; 00208 LPWSTR lpwValidChar = (LPWSTR)lpwCurrentChar; 00209 00210 00211 if (lpwCurrentChar > lpwStart) { 00212 // 00213 // Examine each code element. Skip all combining elements. 00214 // 00215 while (lpwCurrentChar-- > lpwStart) { 00216 if (!GetStringTypeW( 00217 CT_CTYPE3, 00218 lpwCurrentChar, 00219 1, 00220 &ctype3info)) { 00221 /* 00222 * GetStringTypeW failed! The caller is not expecting failure, 00223 * CharPrevW does not have a failure indicator, so just return 00224 * a pointer to the character we couldn't analyze. 00225 */ 00226 RIPMSG2(RIP_WARNING, "CharPrevW failed, L'\\x%.4x' at %#p", 00227 *lpwCurrentChar, lpwCurrentChar); 00228 break; 00229 } 00230 if (!((ctype3info & C3_NONSPACING) && (!(ctype3info & C3_ALPHA)))) { 00231 lpwValidChar = (LPWSTR)lpwCurrentChar; 00232 break; // found non-combining code element 00233 } 00234 } 00235 } 00236 00237 return (LPWSTR)lpwValidChar; 00238 }

DWORD WINAPI CharUpperBuffW LPWSTR  pwsz,
DWORD  cwch
 

Definition at line 298 of file wstrings.c.

References DWORD, IS_UNICODE_BLK1, IsCharLowerA(), LATIN_SMALL_LETTER_SHARP_S, and LATIN_SMALL_LETTER_Y_DIAERESIS.

Referenced by CharUpperBuffA(), CharUpperW(), ECInsertText(), and xxxLBInsertItem().

00301 { 00302 int cwchT; 00303 DWORD i; 00304 00305 if (cwch == 0) { 00306 return 0; 00307 } 00308 00309 cwchT = LCMapStringW(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, 00310 pwsz, cwch, pwsz, cwch); 00311 00312 if (cwchT != 0) { 00313 return cwchT; 00314 } 00315 00316 /* 00317 * LCMapString failed! The caller is not expecting failure, 00318 * CharUpperBuffW does not have a failure indicator, so we 00319 * convert the buffer to upper case as best we can. 00320 */ 00321 RIPMSG1(RIP_WARNING, "CharUpperBuffW(%ls) failed", pwsz); 00322 00323 for (i=0; i < cwch; i++) { 00324 if (IS_UNICODE_BLK1(pwsz[i]) && 00325 IsCharLowerA((char)pwsz[i]) && 00326 (pwsz[i] != LATIN_SMALL_LETTER_SHARP_S) && 00327 (pwsz[i] != LATIN_SMALL_LETTER_Y_DIAERESIS)) { 00328 pwsz[i] += (WCHAR)('A'-'a'); 00329 } 00330 } 00331 00332 return cwch; 00333 }

LPWSTR WINAPI CharUpperW LPWSTR  pwsz  ) 
 

Definition at line 102 of file wstrings.c.

References CharUpperBuffW(), IS_PTR, and NULL.

00104 { 00105 /* 00106 * Early out for NULL string or '\0' 00107 */ 00108 if (pwsz == NULL) { 00109 return pwsz; 00110 } 00111 00112 if (!IS_PTR(pwsz)) { 00113 if (!LCMapStringW( 00114 LOCALE_USER_DEFAULT, 00115 LCMAP_UPPERCASE, 00116 (LPWSTR)&pwsz, 00117 1, 00118 (LPWSTR)&pwsz, 00119 1 00120 )) { 00121 /* 00122 * We don't expect LCMapString to fail! The caller is not expecting 00123 * failure, CharLowerW does not have a failure indicator, so we do 00124 * nothing. 00125 */ 00126 RIPMSG1(RIP_WARNING, "CharUpperW(%#p): LCMapString failed", pwsz); 00127 } 00128 00129 return pwsz; 00130 } 00131 00132 /* 00133 * pwsz is a null-terminated string 00134 */ 00135 CharUpperBuffW(pwsz, wcslen(pwsz)+1); 00136 return pwsz; 00137 }

BOOL WINAPI IsCharAlphaNumericW WCHAR  wChar  ) 
 

Definition at line 427 of file wstrings.c.

References BOOL, FALSE, and TRUE.

00429 { 00430 WORD ctype1info; 00431 00432 if (!GetStringTypeW(CT_CTYPE1, &wChar, 1, &ctype1info)) { 00433 // 00434 // GetStringTypeW returned an error! IsCharAlphaNumericW has no 00435 // provision for returning an error... The best we can do is to 00436 // return FALSE 00437 // 00438 UserAssert(FALSE); 00439 return FALSE; 00440 } 00441 // 00442 // LATER 20 Feb 92 GregoryW 00443 // We may need to check ctype 3 info if we want to check for 00444 // digits other than ASCII '0'-'9' (such as Lao digits or 00445 // Tibetan digits, etc.). 00446 // 00447 #ifdef FE_SB // IsCharAlphaNumericW() 00448 if (ctype1info & C1_ALPHA) { 00449 WORD ctype3info = 0; 00450 /* 00451 * We don't want to return TRUE for halfwidth katakana. 00452 * Katakana is linguistic character (C1_ALPHA), but it is not 00453 * alphabet character. 00454 */ 00455 if (!GetStringTypeW(CT_CTYPE3, &wChar, 1, &ctype3info)) { 00456 UserAssert(FALSE); 00457 /* 00458 * Assume, it is alphabet character, because it has 00459 * C1_ALPHA attribute. 00460 */ 00461 return TRUE; 00462 } 00463 00464 if (ctype3info & (C3_KATAKANA|C3_HIRAGANA)) { 00465 /* 00466 * This is 'Katakana'. 00467 */ 00468 return FALSE; 00469 } else { 00470 return TRUE; 00471 } 00472 } else if (ctype1info & C1_DIGIT) { 00473 return TRUE; 00474 } else { 00475 return FALSE; 00476 } 00477 #else 00478 if ((ctype1info & C1_ALPHA) || (ctype1info & C1_DIGIT)) { 00479 return TRUE; 00480 } else { 00481 return FALSE; 00482 } 00483 #endif // FE_SB 00484 }

BOOL WINAPI IsCharAlphaW WCHAR  wChar  ) 
 

Definition at line 499 of file wstrings.c.

References BOOL, FALSE, and TRUE.

00501 { 00502 WORD ctype1info; 00503 00504 if (!GetStringTypeW(CT_CTYPE1, &wChar, 1, &ctype1info)) { 00505 // 00506 // GetStringTypeW returned an error! IsCharAlphaW has no 00507 // provision for returning an error... The best we can do 00508 // is to return FALSE 00509 // 00510 UserAssert(FALSE); 00511 return FALSE; 00512 } 00513 if (ctype1info & C1_ALPHA) { 00514 #ifdef FE_SB // IsCharAlphaA() 00515 WORD ctype3info = 0; 00516 /* 00517 * We don't want to return TRUE for halfwidth katakana. 00518 * Katakana is linguistic character (C1_ALPHA), but it is not 00519 * alphabet character. 00520 */ 00521 if (!GetStringTypeW(CT_CTYPE3, &wChar, 1, &ctype3info)) { 00522 UserAssert(FALSE); 00523 /* 00524 * Assume, it is alphabet character, because it has 00525 * C1_ALPHA attribute. 00526 */ 00527 return TRUE; 00528 } 00529 00530 if (ctype3info & (C3_KATAKANA|C3_HIRAGANA)) { 00531 /* 00532 * This is 'Katakana'. 00533 */ 00534 return FALSE; 00535 } else { 00536 return TRUE; 00537 } 00538 #else 00539 return TRUE; 00540 #endif // FE_SB 00541 } else { 00542 return FALSE; 00543 } 00544 }

BOOL WINAPI IsCharLowerW WCHAR  wChar  ) 
 

Definition at line 348 of file wstrings.c.

References BOOL, CHAR, FALSE, IS_UNICODE_BLK1, IsCharLowerA(), and TRUE.

Referenced by ECInsertText().

00350 { 00351 WORD ctype1info; 00352 00353 if (GetStringTypeW(CT_CTYPE1, &wChar, 1, &ctype1info)) { 00354 if (ctype1info & C1_LOWER) { 00355 return TRUE; 00356 } else { 00357 return FALSE; 00358 } 00359 } 00360 00361 /* 00362 * GetStringTypeW failed! The caller is not expecting 00363 * failure, IsCharLowerW does not have a failure indicator, so we 00364 * determine the case as best we can. 00365 */ 00366 RIPMSG1(RIP_WARNING, "IsCharLowerW(L'\\x%.4lx') failed", wChar); 00367 00368 if (IS_UNICODE_BLK1(wChar)) { 00369 return IsCharLowerA((CHAR)wChar); 00370 } else { 00371 return FALSE; 00372 } 00373 }

BOOL WINAPI IsCharUpperW WCHAR  wChar  ) 
 

Definition at line 387 of file wstrings.c.

References BOOL, CHAR, FALSE, IS_UNICODE_BLK1, IsCharUpperA(), and TRUE.

00389 { 00390 WORD ctype1info; 00391 00392 if (GetStringTypeW(CT_CTYPE1, &wChar, 1, &ctype1info)) { 00393 if (ctype1info & C1_UPPER) { 00394 return TRUE; 00395 } else { 00396 return FALSE; 00397 } 00398 } 00399 00400 /* 00401 * GetStringTypeW failed! The caller is not expecting 00402 * failure, IsCharLowerW does not have a failure indicator, so we 00403 * determine the case as best we can. 00404 */ 00405 RIPMSG1(RIP_WARNING, "IsCharUpper(L'\\x%.4lx') failed", wChar); 00406 00407 if (IS_UNICODE_BLK1(wChar)) { 00408 return IsCharUpperA((CHAR)wChar); 00409 } else { 00410 return FALSE; 00411 } 00412 }


Generated on Sat May 15 19:46:10 2004 for test by doxygen 1.3.7