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

strings.c File Reference

#include "precomp.h"

Go to the source code of this file.

Defines

#define LATIN_CAPITAL_LETTER_A_GRAVE   (CHAR)0xc0
#define LATIN_CAPITAL_LETTER_THORN   (CHAR)0xde
#define LATIN_SMALL_LETTER_SHARP_S   (CHAR)0xdf
#define LATIN_SMALL_LETTER_Y_DIAERESIS   (CHAR)0xff
#define DIVISION_SIGN   (CHAR)0xf7
#define MULTIPLICATION_SIGN   (CHAR)0xd7
#define CCH_LOCAL_BUFF   256

Functions

LPSTR WINAPI CharLowerA (LPSTR psz)
LPSTR WINAPI CharUpperA (LPSTR psz)
LPSTR WINAPI CharNextA (LPCSTR lpCurrentChar)
LPSTR WINAPI CharNextExA (WORD CodePage, LPCSTR lpCurrentChar, DWORD dwFlags)
LPSTR WINAPI CharPrevA (LPCSTR lpStart, LPCSTR lpCurrentChar)
LPSTR WINAPI CharPrevExA (WORD CodePage, LPCSTR lpStart, LPCSTR lpCurrentChar, DWORD dwFlags)
DWORD WINAPI CharLowerBuffA (LPSTR psz, DWORD nLength)
DWORD WINAPI CharUpperBuffA (LPSTR psz, DWORD nLength)
BOOL WINAPI IsCharLowerA (char cChar)
BOOL WINAPI IsCharUpperA (char cChar)
BOOL WINAPI IsCharAlphaNumericA (char cChar)
BOOL WINAPI IsCharAlphaA (char cChar)


Define Documentation

#define CCH_LOCAL_BUFF   256
 

Definition at line 333 of file strings.c.

Referenced by CharLowerBuffA(), and CharUpperBuffA().

#define DIVISION_SIGN   (CHAR)0xf7
 

Definition at line 26 of file strings.c.

#define LATIN_CAPITAL_LETTER_A_GRAVE   (CHAR)0xc0
 

Definition at line 22 of file strings.c.

#define LATIN_CAPITAL_LETTER_THORN   (CHAR)0xde
 

Definition at line 23 of file strings.c.

#define LATIN_SMALL_LETTER_SHARP_S   (CHAR)0xdf
 

Definition at line 24 of file strings.c.

Referenced by CharUpperBuffA(), and CharUpperBuffW().

#define LATIN_SMALL_LETTER_Y_DIAERESIS   (CHAR)0xff
 

Definition at line 25 of file strings.c.

Referenced by CharUpperBuffA(), and CharUpperBuffW().

#define MULTIPLICATION_SIGN   (CHAR)0xd7
 

Definition at line 27 of file strings.c.


Function Documentation

LPSTR WINAPI CharLowerA LPSTR  psz  ) 
 

Definition at line 46 of file strings.c.

References BYTE, CHAR, CharLowerBuffA(), IS_DBCS_ENABLED, IS_PTR, NT_SUCCESS, NTSTATUS(), NULL, RtlMultiByteToUnicodeN(), RtlUnicodeToMultiByteN(), and strlen().

00048 { 00049 NTSTATUS st; 00050 00051 /* 00052 * Early out for NULL string or '\0' 00053 */ 00054 if (psz == NULL) { 00055 return psz; 00056 } 00057 00058 if (!IS_PTR(psz)) { 00059 WCHAR wch; 00060 00061 #ifdef FE_SB // CharLowerA() 00062 /* 00063 * if only DBCS Leadbyte was passed, just return the character. 00064 * Same behavior as Windows 3.1J and Windows 95 FarEast version. 00065 */ 00066 if (IS_DBCS_ENABLED() && IsDBCSLeadByte((BYTE)(ULONG_PTR)psz)) { 00067 return psz; 00068 } 00069 #endif // FE_SB 00070 00071 // 00072 // LATER 14 Feb 92 GregoryW 00073 // For DBCS code pages is a double byte character ever 00074 // passed in the low word of psz or is the high nibble 00075 // of the low word always ignored? 00076 // 00077 st = RtlMultiByteToUnicodeN(&wch, sizeof(WCHAR), NULL, (PCH)&psz, sizeof(CHAR)); 00078 if (!NT_SUCCESS(st)) { 00079 /* 00080 * Failed! Caller is not expecting failure, CharLowerA does not 00081 * have a failure indicator, so just return the original character. 00082 */ 00083 RIPMSG1(RIP_WARNING, "CharLowerA(%#p) failed\n", psz); 00084 } else { 00085 /* 00086 * The next two calls never fail. 00087 */ 00088 LCMapStringW(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, &wch, 1, &wch, 1); 00089 RtlUnicodeToMultiByteN((PCH)&psz, sizeof(CHAR), NULL, &wch, sizeof(WCHAR)); 00090 } 00091 return psz; 00092 00093 } 00094 00095 /* 00096 * psz is a null-terminated string 00097 */ 00098 CharLowerBuffA(psz, strlen(psz)+1); 00099 return psz; 00100 }

DWORD WINAPI CharLowerBuffA LPSTR  psz,
DWORD  nLength
 

Definition at line 335 of file strings.c.

References CCH_LOCAL_BUFF, CharLowerBuffW(), DWORD, IS_DBCS_ENABLED, IsCharUpperA(), RtlUnicodeToMultiByteN(), and UserLocalFree.

Referenced by CharLowerA(), and ECInsertText().

00338 { 00339 ULONG cb; 00340 WCHAR awchLocal[CCH_LOCAL_BUFF]; 00341 LPWSTR pwszT = awchLocal; 00342 int cwch; 00343 00344 if (nLength == 0) { 00345 return(0); 00346 } 00347 00348 /* 00349 * Convert ANSI to Unicode. 00350 * Use awchLocal if it is big enough, otherwise allocate space. 00351 */ 00352 cwch = MBToWCS( 00353 psz, // ANSI buffer 00354 nLength, // length of buffer 00355 &pwszT, // address of Unicode string 00356 (nLength > CCH_LOCAL_BUFF ? -1 : nLength), 00357 (nLength > CCH_LOCAL_BUFF) ); 00358 00359 if (cwch != 0) { 00360 CharLowerBuffW(pwszT, cwch); 00361 00362 /* 00363 * This can't fail 00364 */ 00365 RtlUnicodeToMultiByteN( 00366 psz, // ANSI string 00367 nLength, // given to us 00368 &cb, // result length 00369 pwszT, // Unicode string 00370 cwch * sizeof(WCHAR)); // length IN BYTES 00371 00372 if (pwszT != awchLocal) { 00373 UserLocalFree(pwszT); 00374 } 00375 00376 return (DWORD)cb; 00377 } 00378 00379 /* 00380 * MBToWCS failed! The caller is not expecting failure, 00381 * so we convert the string to lower case as best we can. 00382 */ 00383 RIPMSG2(RIP_WARNING, 00384 "CharLowerBuffA(%#p, %lx) failed\n", psz, nLength); 00385 00386 for (cb=0; cb < nLength; cb++) { 00387 #ifdef FE_SB // CharLowerBuffA(): skip double byte character 00388 if (IS_DBCS_ENABLED() && IsDBCSLeadByte(psz[cb])) { 00389 cb++; 00390 } else if (IsCharUpperA(psz[cb])) { 00391 psz[cb] += 'a'-'A'; 00392 } 00393 #else 00394 if (IsCharUpperA(psz[cb])) { 00395 psz[cb] += 'a'-'A'; 00396 } 00397 #endif // FE_SB 00398 } 00399 00400 return nLength; 00401 }

LPSTR WINAPI CharNextA LPCSTR  lpCurrentChar  ) 
 

Definition at line 190 of file strings.c.

References IS_DBCS_ENABLED.

Referenced by CompStrAToCharA(), and CompStrAToCharW().

00192 { 00193 #ifdef FE_SB // CharNextA(): dbcs enabling 00194 if (IS_DBCS_ENABLED() && IsDBCSLeadByte(*lpCurrentChar)) { 00195 lpCurrentChar++; 00196 } 00197 /* 00198 * if we have only DBCS LeadingByte, we will point string-terminaler. 00199 */ 00200 #endif // FE_SB 00201 00202 if (*lpCurrentChar) { 00203 lpCurrentChar++; 00204 } 00205 return (LPSTR)lpCurrentChar; 00206 }

LPSTR WINAPI CharNextExA WORD  CodePage,
LPCSTR  lpCurrentChar,
DWORD  dwFlags
 

Definition at line 218 of file strings.c.

References dwFlags, and NULL.

00222 { 00223 if (lpCurrentChar == (LPSTR)NULL) 00224 { 00225 return (LPSTR)lpCurrentChar; 00226 } 00227 00228 if (IsDBCSLeadByteEx(CodePage, *lpCurrentChar)) 00229 { 00230 lpCurrentChar++; 00231 } 00232 00233 if (*lpCurrentChar) 00234 { 00235 lpCurrentChar++; 00236 } 00237 return (LPSTR)lpCurrentChar; 00238 00239 UNREFERENCED_PARAMETER(dwFlags); 00240 }

LPSTR WINAPI CharPrevA LPCSTR  lpStart,
LPCSTR  lpCurrentChar
 

Definition at line 257 of file strings.c.

References BOOL, FALSE, and IS_DBCS_ENABLED.

00260 { 00261 #ifdef FE_SB // CharPrevA : dbcs enabling 00262 if (lpCurrentChar > lpStart) { 00263 if (IS_DBCS_ENABLED()) { 00264 LPCSTR lpChar; 00265 BOOL bDBC = FALSE; 00266 00267 for (lpChar = --lpCurrentChar - 1 ; lpChar >= lpStart ; lpChar--) { 00268 if (!IsDBCSLeadByte(*lpChar)) 00269 break; 00270 bDBC = !bDBC; 00271 } 00272 00273 if (bDBC) 00274 lpCurrentChar--; 00275 } 00276 else 00277 lpCurrentChar--; 00278 } 00279 return (LPSTR)lpCurrentChar; 00280 #else 00281 if (lpCurrentChar > lpStart) { 00282 lpCurrentChar--; 00283 } 00284 return (LPSTR)lpCurrentChar; 00285 #endif // FE_SB 00286 }

LPSTR WINAPI CharPrevExA WORD  CodePage,
LPCSTR  lpStart,
LPCSTR  lpCurrentChar,
DWORD  dwFlags
 

Definition at line 297 of file strings.c.

References BOOL, dwFlags, and FALSE.

00302 { 00303 if (lpCurrentChar > lpStart) { 00304 LPCSTR lpChar; 00305 BOOL bDBC = FALSE; 00306 00307 for (lpChar = --lpCurrentChar - 1 ; lpChar >= lpStart ; lpChar--) { 00308 if (!IsDBCSLeadByteEx(CodePage, *lpChar)) 00309 break; 00310 bDBC = !bDBC; 00311 } 00312 00313 if (bDBC) 00314 lpCurrentChar--; 00315 } 00316 return (LPSTR)lpCurrentChar; 00317 00318 UNREFERENCED_PARAMETER(dwFlags); 00319 }

LPSTR WINAPI CharUpperA LPSTR  psz  ) 
 

Definition at line 119 of file strings.c.

References BYTE, CHAR, CharUpperBuffA(), IS_DBCS_ENABLED, IS_PTR, NT_SUCCESS, NTSTATUS(), NULL, RtlMultiByteToUnicodeN(), RtlUnicodeToMultiByteN(), and strlen().

00121 { 00122 NTSTATUS st; 00123 00124 /* 00125 * Early out for NULL string or '\0' 00126 */ 00127 if (psz == NULL) { 00128 return psz; 00129 } 00130 00131 if (!IS_PTR(psz)) { 00132 WCHAR wch; 00133 00134 #ifdef FE_SB // CharLowerA() 00135 /* 00136 * if only DBCS Leadbyte was passed, just return the character. 00137 * Same behavior as Windows 3.1J and Windows 95 FarEast version. 00138 */ 00139 if (IS_DBCS_ENABLED() && IsDBCSLeadByte((BYTE)(ULONG_PTR)psz)) { 00140 return psz; 00141 } 00142 #endif // FE_SB 00143 00144 // 00145 // LATER 14 Feb 92 GregoryW 00146 // For DBCS code pages is a double byte character ever 00147 // passed in the low word of psz or is the high nibble 00148 // of the low word always ignored? 00149 // 00150 st = RtlMultiByteToUnicodeN(&wch, sizeof(WCHAR), NULL, (PCH)&psz, sizeof(CHAR)); 00151 if (!NT_SUCCESS(st)) { 00152 /* 00153 * Failed! Caller is not expecting failure, CharUpperA does not 00154 * have a failure indicator, so return the original character. 00155 */ 00156 RIPMSG1(RIP_WARNING, "CharUpperA(%#p) failed\n", psz); 00157 } else { 00158 /* 00159 * The next two calls never fail. 00160 */ 00161 LCMapStringW(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, &wch, 1, &wch, 1); 00162 RtlUnicodeToMultiByteN((PCH)&psz, sizeof(CHAR), NULL, &wch, sizeof(WCHAR)); 00163 } 00164 return psz; 00165 00166 } 00167 00168 /* 00169 * psz is a null-terminated string 00170 */ 00171 CharUpperBuffA(psz, strlen(psz)+1); 00172 return psz; 00173 }

DWORD WINAPI CharUpperBuffA LPSTR  psz,
DWORD  nLength
 

Definition at line 416 of file strings.c.

References CCH_LOCAL_BUFF, CharUpperBuffW(), DWORD, IS_DBCS_ENABLED, IsCharLowerA(), LATIN_SMALL_LETTER_SHARP_S, LATIN_SMALL_LETTER_Y_DIAERESIS, RtlUnicodeToMultiByteN(), and UserLocalFree.

Referenced by CharUpperA(), and ECInsertText().

00419 { 00420 DWORD cb; 00421 WCHAR awchLocal[CCH_LOCAL_BUFF]; 00422 LPWSTR pwszT = awchLocal; 00423 int cwch; 00424 00425 if (nLength==0) { 00426 return(0); 00427 } 00428 00429 /* 00430 * Convert ANSI to Unicode. 00431 * Use awchLocal if it is big enough, otherwise allocate space. 00432 */ 00433 cwch = MBToWCS( 00434 psz, // ANSI buffer 00435 nLength, // length of buffer 00436 &pwszT, // address of Unicode string 00437 (nLength > CCH_LOCAL_BUFF ? -1 : nLength), 00438 (nLength > CCH_LOCAL_BUFF) ); 00439 00440 if (cwch != 0) { 00441 CharUpperBuffW(pwszT, cwch); 00442 00443 RtlUnicodeToMultiByteN( 00444 psz, // address of ANSI string 00445 nLength, // given to us 00446 &cb, // result length 00447 pwszT, // Unicode string 00448 cwch * sizeof(WCHAR)); // length IN BYTES 00449 00450 if (pwszT != awchLocal) { 00451 UserLocalFree(pwszT); 00452 } 00453 00454 return (DWORD)cb; 00455 } 00456 00457 /* 00458 * MBToWCS failed! The caller is not expecting failure, 00459 * so we convert the string to upper case as best we can. 00460 */ 00461 RIPMSG2(RIP_WARNING, 00462 "CharLowerBuffA(%#p, %lx) failed\n", psz, nLength); 00463 00464 for (cb=0; cb < nLength; cb++) { 00465 #ifdef FE_SB // CharUpperBuffA(): skip double byte characters 00466 if (IS_DBCS_ENABLED() && IsDBCSLeadByte(psz[cb])) { 00467 cb++; 00468 } else if (IsCharLowerA(psz[cb]) && 00469 /* 00470 * Sometime, LATIN_xxxx code is DBCS LeadingByte depending on ACP. 00471 * In that case, we never come here... 00472 */ 00473 (psz[cb] != LATIN_SMALL_LETTER_SHARP_S) && 00474 (psz[cb] != LATIN_SMALL_LETTER_Y_DIAERESIS)) { 00475 psz[cb] += 'A'-'a'; 00476 } 00477 #else 00478 if (IsCharLowerA(psz[cb]) && 00479 (psz[cb] != LATIN_SMALL_LETTER_SHARP_S) && 00480 (psz[cb] != LATIN_SMALL_LETTER_Y_DIAERESIS)) { 00481 psz[cb] += 'A'-'a'; 00482 } 00483 #endif // FE_SB 00484 } 00485 00486 return nLength; 00487 }

BOOL WINAPI IsCharAlphaA char  cChar  ) 
 

Definition at line 623 of file strings.c.

References BOOL, CHAR, FALSE, IS_DBCS_ENABLED, NULL, RtlMultiByteToUnicodeN(), and TRUE.

00625 { 00626 WORD ctype1info = 0; 00627 WCHAR wChar = 0; 00628 00629 /* 00630 * The following 2 calls cannot fail here 00631 */ 00632 RtlMultiByteToUnicodeN(&wChar, sizeof(WCHAR), NULL, &cChar, sizeof(CHAR)); 00633 GetStringTypeW(CT_CTYPE1, &wChar, 1, &ctype1info); 00634 #ifdef FE_SB // IsCharAlphaA() 00635 if ((ctype1info & C1_ALPHA) == C1_ALPHA) { 00636 WORD ctype3info = 0; 00637 if (!IS_DBCS_ENABLED()) { 00638 return TRUE; 00639 } 00640 /* 00641 * We don't want to return TRUE for halfwidth katakana. 00642 * Katakana is linguistic character (C1_ALPHA), but it is not 00643 * alphabet character. 00644 */ 00645 GetStringTypeW(CT_CTYPE3, &wChar, 1, &ctype3info); 00646 return ((ctype3info & (C3_KATAKANA|C3_HIRAGANA)) ? FALSE : TRUE); 00647 } 00648 return (FALSE); 00649 #else 00650 return (ctype1info & C1_ALPHA) == C1_ALPHA; 00651 #endif // FE_SB 00652 }

BOOL WINAPI IsCharAlphaNumericA char  cChar  ) 
 

Definition at line 577 of file strings.c.

References BOOL, CHAR, FALSE, IS_DBCS_ENABLED, NULL, RtlMultiByteToUnicodeN(), and TRUE.

00579 { 00580 WORD ctype1info = 0; 00581 WCHAR wChar = 0; 00582 00583 /* 00584 * The following 2 calls cannot fail here 00585 */ 00586 RtlMultiByteToUnicodeN(&wChar, sizeof(WCHAR), NULL, &cChar, sizeof(CHAR)); 00587 GetStringTypeW(CT_CTYPE1, &wChar, 1, &ctype1info); 00588 #ifdef FE_SB // IsCharAlphaNumericA() 00589 if (ctype1info & C1_ALPHA) { 00590 WORD ctype3info = 0; 00591 if (!IS_DBCS_ENABLED()) { 00592 return TRUE; 00593 } 00594 /* 00595 * We don't want to return TRUE for halfwidth katakana. 00596 * Katakana is linguistic character (C1_ALPHA), but it is not 00597 * alphabet character. 00598 */ 00599 GetStringTypeW(CT_CTYPE3, &wChar, 1, &ctype3info); 00600 return ((ctype3info & (C3_KATAKANA|C3_HIRAGANA)) ? FALSE : TRUE); 00601 } 00602 /* Otherwise, it might be digits ? */ 00603 return !!(ctype1info & C1_DIGIT); 00604 #else 00605 return (ctype1info & C1_ALPHA) || (ctype1info & C1_DIGIT); 00606 #endif // FE_SB 00607 }

BOOL WINAPI IsCharLowerA char  cChar  ) 
 

Definition at line 502 of file strings.c.

References BOOL, CHAR, FALSE, IS_DBCS_ENABLED, NULL, and RtlMultiByteToUnicodeN().

Referenced by CharUpperBuffA(), CharUpperBuffW(), ECInsertText(), and IsCharLowerW().

00504 { 00505 WORD ctype1info = 0; 00506 WCHAR wChar = 0; 00507 00508 #ifdef FE_SB // IsCharLowerA() 00509 /* 00510 * if only DBCS Leadbyte was passed, just return FALSE. 00511 * Same behavior as Windows 3.1J and Windows 95 FarEast version. 00512 */ 00513 if (IS_DBCS_ENABLED() && IsDBCSLeadByte(cChar)) { 00514 return FALSE; 00515 } 00516 #endif // FE_SB 00517 00518 /* 00519 * The following 2 calls cannot fail here 00520 */ 00521 RtlMultiByteToUnicodeN(&wChar, sizeof(WCHAR), NULL, &cChar, sizeof(CHAR)); 00522 GetStringTypeW(CT_CTYPE1, &wChar, 1, &ctype1info); 00523 return (ctype1info & C1_LOWER) == C1_LOWER; 00524 }

BOOL WINAPI IsCharUpperA char  cChar  ) 
 

Definition at line 538 of file strings.c.

References BOOL, CHAR, FALSE, IS_DBCS_ENABLED, NULL, and RtlMultiByteToUnicodeN().

Referenced by CharLowerBuffA(), CharLowerBuffW(), and IsCharUpperW().

00540 { 00541 WORD ctype1info = 0; 00542 WCHAR wChar = 0; 00543 00544 #ifdef FE_SB // IsCharUpperA() 00545 /* 00546 * if only DBCS Leadbyte was passed, just return FALSE. 00547 * Same behavior as Windows 3.1J and Windows 95 FarEast version. 00548 */ 00549 if (IS_DBCS_ENABLED() && IsDBCSLeadByte(cChar)) { 00550 return FALSE; 00551 } 00552 #endif // FE_SB 00553 00554 /* 00555 * The following 2 calls cannot fail here 00556 */ 00557 RtlMultiByteToUnicodeN(&wChar, sizeof(WCHAR), NULL, &cChar, sizeof(CHAR)); 00558 GetStringTypeW(CT_CTYPE1, &wChar, 1, &ctype1info); 00559 return (ctype1info & C1_UPPER) == C1_UPPER; 00560 }


Generated on Sat May 15 19:45:42 2004 for test by doxygen 1.3.7