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

chartran.c File Reference

Go to the source code of this file.

Defines

#define THREAD_CODEPAGE()   (GetClientInfo()->CodePage)
#define IS_ACP(cp)   (((cp) == NlsAnsiCodePage) || ((cp) == CP_ACP))

Functions

 __declspec (dllimport)
int MBToWCSEx (WORD wCodePage, LPCSTR pAnsiString, int nAnsiChar, LPWSTR *ppUnicodeString, int cchUnicodeString, BOOL bAllocateMem)
BOOL RtlWCSMessageWParamCharToMB (DWORD msg, WPARAM *pWParam)
BOOL RtlMBMessageWParamCharToWCS (DWORD msg, WPARAM *pWParam)
VOID RtlInitLargeAnsiString (PLARGE_ANSI_STRING plstr, LPCSTR psz, UINT cchLimit)
VOID RtlInitLargeUnicodeString (PLARGE_UNICODE_STRING plstr, LPCWSTR psz, UINT cchLimit)


Define Documentation

#define IS_ACP cp   )     (((cp) == NlsAnsiCodePage) || ((cp) == CP_ACP))
 

Referenced by __declspec(), MBToWCSEx(), RtlMBMessageWParamCharToWCS(), and RtlWCSMessageWParamCharToMB().

 
#define THREAD_CODEPAGE  )     (GetClientInfo()->CodePage)
 


Function Documentation

__declspec dllimport   ) 
 

Definition at line 16 of file chartran.c.

References DBCS_CHARSIZE, FALSE, INT, IS_ACP, NT_SUCCESS, NTSTATUS(), NULL, RtlUnicodeToMultiByteN(), Status, UINT, UserRtlAllocMem(), and UserRtlFreeMem().

Referenced by IsMidEastEnabledSystem(), and xxxInternalToUnicode().

00043 : number of characters in the output string 00044 * If bAllocateMem was TRUE, then FreeAnsiString() may be 00045 * used to free the allocated memory at *ppAnsiString. 00046 * Failure: 0 means failure 00047 * (Any buffers allocated by this routine are freed) 00048 * 00049 * History: 00050 * 1992-??-?? GregoryW Created 00051 * 1993-01-07 IanJa fix memory leak on error case. 00052 \***************************************************************************/ 00053 00054 int 00055 WCSToMBEx( 00056 WORD wCodePage, 00057 LPCWSTR pUnicodeString, 00058 int cchUnicodeString, 00059 LPSTR *ppAnsiString, 00060 int nAnsiChar, 00061 BOOL bAllocateMem) 00062 { 00063 ULONG nCharsInAnsiString; 00064 #ifdef _USERK_ 00065 INT iCharsInAnsiString; 00066 #endif // _USERK_ 00067 00068 if (nAnsiChar == 0 || cchUnicodeString == 0 || pUnicodeString == NULL) { 00069 return 0; // nothing to translate or nowhere to put it 00070 } 00071 00072 /* 00073 * Adjust the cchUnicodeString value. If cchUnicodeString == -1 then the 00074 * string pointed to by pUnicodeString is NUL terminated so we 00075 * count the number of bytes. If cchUnicodeString < -1 this is an 00076 * illegal value so we return FALSE. Otherwise, cchUnicodeString is 00077 * set and requires no adjustment. 00078 */ 00079 if (cchUnicodeString == -1) { 00080 cchUnicodeString = (wcslen(pUnicodeString) + 1); 00081 } else if (cchUnicodeString < -1) { 00082 return 0; // illegal value 00083 } 00084 00085 /* 00086 * Adjust the nAnsiChar value. If nAnsiChar == -1 then we pick a 00087 * value based on cchUnicodeString to hold the converted string. If 00088 * nAnsiChar < -1 this is an illegal value so we return FALSE. 00089 * Otherwise, nAnsiChar is set and requires no adjustment. 00090 */ 00091 if (nAnsiChar == -1) { 00092 if (bAllocateMem == FALSE) { 00093 return 0; // no destination 00094 } 00095 nAnsiChar = cchUnicodeString * DBCS_CHARSIZE; 00096 } else if (nAnsiChar < -1) { 00097 return 0; // illegal value 00098 } 00099 00100 if (bAllocateMem) { 00101 /* 00102 * We need to allocate memory to hold the translated string. 00103 */ 00104 *ppAnsiString = (LPSTR)UserRtlAllocMem(nAnsiChar); 00105 if (*ppAnsiString == NULL) { 00106 return 0; 00107 } 00108 } 00109 00110 /* 00111 * translate Unicode string pointed to by pUnicodeString into 00112 * ANSI and store in location pointed to by pAnsiString. We 00113 * stop translating when we fill up the ANSI buffer or reach 00114 * the end of the Unicode string. 00115 */ 00116 00117 /* 00118 * if the target multibyte codepage is eqaul to ACP, Call faster Rtl function. 00119 */ 00120 if (IS_ACP(wCodePage)) { 00121 00122 NTSTATUS Status; 00123 00124 Status = RtlUnicodeToMultiByteN( 00125 (PCH)*ppAnsiString, 00126 nAnsiChar, 00127 &nCharsInAnsiString, 00128 (PWCH)pUnicodeString, 00129 cchUnicodeString * sizeof(WCHAR)); 00130 /* 00131 * If the ansi buffer is too small, RtlUnicodeToMultiByteN() 00132 * returns STATUS_BUFFER_OVERFLOW. In this case, the function 00133 * put as many ansi characters as specified in the buffer and 00134 * returns the number by chacacters(in bytes) written. We would 00135 * like to return the actual byte count written in the ansi 00136 * buffer rather than returnning 0 since callers of this function 00137 * don't expect to be returned 0 in most case. 00138 */ 00139 00140 if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) { 00141 if (bAllocateMem) { 00142 UserRtlFreeMem(*ppAnsiString); 00143 } 00144 return 0; // translation failed 00145 } 00146 00147 return (int)nCharsInAnsiString; 00148 00149 } else { 00150 00151 #ifdef _USERK_ 00152 /* 00153 * Call GRE to convert string to Unicode. (Kernel mode) 00154 */ 00155 00156 iCharsInAnsiString = EngWideCharToMultiByte( 00157 (UINT)wCodePage, 00158 (LPWSTR)pUnicodeString, 00159 cchUnicodeString * sizeof(WCHAR), 00160 (LPSTR)*ppAnsiString, 00161 nAnsiChar); 00162 00163 nCharsInAnsiString = (iCharsInAnsiString == -1) ? 0 : 00164 (ULONG) iCharsInAnsiString; 00165 00166 #else 00167 /* 00168 * Call NLS API (Kernel32) to convert string to Unicode. (User mode) 00169 */ 00170 nCharsInAnsiString = WideCharToMultiByte( 00171 (UINT)wCodePage, 0, 00172 (LPCWSTR)pUnicodeString, 00173 cchUnicodeString, 00174 (LPSTR)*ppAnsiString, 00175 nAnsiChar, 00176 NULL, NULL); 00177 #endif // _USERK_ 00178 00179 if (nCharsInAnsiString == 0) { 00180 if (bAllocateMem) { 00181 UserRtlFreeMem(*ppAnsiString); 00182 } 00183 } 00184 00185 return (int)nCharsInAnsiString; 00186 } 00187 }

int MBToWCSEx WORD  wCodePage,
LPCSTR  pAnsiString,
int  nAnsiChar,
LPWSTR *  ppUnicodeString,
int  cchUnicodeString,
BOOL  bAllocateMem
 

Definition at line 191 of file chartran.c.

References FALSE, INT, IS_ACP, NT_SUCCESS, NULL, RtlMultiByteToUnicodeN(), strlen(), UINT, UserRtlAllocMem(), and UserRtlFreeMem().

Referenced by ComboBoxDBCharHandler(), DrawTextExA(), GetTabbedTextExtentA(), MESSAGECALL(), StaticWndProcWorker(), TabbedTextOutA(), and xxxLBoxCtlCharInput().

00198 { 00199 ULONG nBytesInUnicodeString; 00200 00201 if (nAnsiChar == 0 || cchUnicodeString == 0 || pAnsiString == NULL) { 00202 return 0; // nothing to translate or nowhere to put it 00203 } 00204 00205 /* 00206 * Adjust the nAnsiChar value. If nAnsiChar == -1 then the 00207 * string pointed to by pAnsiString is NUL terminated so we 00208 * count the number of bytes. If nAnsiChar < -1 this is an 00209 * illegal value so we return FALSE. Otherwise, nAnsiChar is 00210 * set and requires no adjustment. 00211 */ 00212 00213 #ifdef _USERK_ 00214 UserAssert(nAnsiChar >= USER_AWCONV_COUNTSTRINGSZ); 00215 #endif 00216 if (nAnsiChar < 0) { 00217 00218 /* 00219 * Bug 268035 - joejo 00220 * Need to fail if the count is a negative number less than -2! 00221 */ 00222 if (nAnsiChar < USER_AWCONV_COUNTSTRINGSZ) { 00223 return 0; 00224 } 00225 00226 #if (USER_AWCONV_COUNTSTRING != -1 || USER_AWCONV_COUNTSTRINGSZ != -2) 00227 #error USER_AWCONV_COUNTSTRING or USER_AWCONV_COUNTSTRINGSZ has unexpected value. 00228 #endif 00229 /* HACK HACK HACK 00230 * If nAnsiChar is -1 (USER_AWCONV_COUNTSTRING), nAnsiChar length will be strlen() + 1, 00231 * to allocate the memory including trailing \0: this is compatible to the original code. 00232 * If nAnsiCahr is -2 (USER_AWCONV_COUNTSTRINGSZ), memory for trailing \0 will not be needed, 00233 * so memory allocation is optimized and the return value would be same as strlen(). 00234 */ 00235 nAnsiChar = strlen(pAnsiString) + 2 + nAnsiChar; // don't forget the NUL if nAnsiChar == -1 00236 00237 if (nAnsiChar == 0) { 00238 return 0; 00239 } 00240 } 00241 00242 /* 00243 * Adjust the cchUnicodeString value. If cchUnicodeString == -1 then we 00244 * pick a value based on nAnsiChar to hold the converted string. If 00245 * cchUnicodeString < -1 this is an illegal value so we return FALSE. 00246 * Otherwise, cchUnicodeString is set and requires no adjustment. 00247 */ 00248 if (cchUnicodeString == -1) { 00249 if (bAllocateMem == FALSE) { 00250 return 0; // no destination 00251 } 00252 cchUnicodeString = nAnsiChar; 00253 } else if (cchUnicodeString < -1) { 00254 return 0; // illegal value 00255 } 00256 00257 if (bAllocateMem) { 00258 *ppUnicodeString = (LPWSTR)UserRtlAllocMem(cchUnicodeString*sizeof(WCHAR)); 00259 if (*ppUnicodeString == NULL) { 00260 return 0; // allocation failed 00261 } 00262 } 00263 00264 /* 00265 * if codepage is CP_ACP, We will call faster RtlXXX function. 00266 */ 00267 if (IS_ACP(wCodePage)) { 00268 /* 00269 * translate ANSI string pointed to by pAnsiString into Unicode 00270 * and store in location pointed to by pUnicodeString. We 00271 * stop translating when we fill up the Unicode buffer or reach 00272 * the end of the ANSI string. 00273 */ 00274 if (!NT_SUCCESS(RtlMultiByteToUnicodeN( 00275 (PWCH)*ppUnicodeString, 00276 cchUnicodeString * sizeof(WCHAR), 00277 &nBytesInUnicodeString, 00278 (PCH)pAnsiString, 00279 nAnsiChar 00280 ))) { 00281 if (bAllocateMem) { 00282 UserRtlFreeMem(*ppUnicodeString); 00283 } 00284 return 0; // translation failed 00285 } 00286 00287 return (int)(nBytesInUnicodeString / sizeof(WCHAR)); 00288 00289 } else { 00290 /* 00291 * if wCodePage is not ACP, Call NLS API. 00292 */ 00293 ULONG nCharsInUnicodeString; 00294 00295 #ifdef _USERK_ 00296 00297 /* 00298 * I believe we will never hit this code which is why I am 00299 * adding this assert. [gerritv] 5-21-96 00300 */ 00301 #define SHOULD_NOT_REACH_HERE 0 00302 UserAssert(SHOULD_NOT_REACH_HERE); 00303 #undef SHOULD_NOT_REACH_HERE 00304 return 0; 00305 00306 #if 0 // FYI: old code 00307 INT iCharsInUnicodeString; 00308 00309 /* 00310 * Call GRE to convert string to Unicode. (Kernel mode) 00311 * I believe we will never hit this code which is why I am 00312 * adding this assert. [gerritv] 5-21-96 00313 */ 00314 00315 UserAssert(0); 00316 00317 iCharsInUnicodeString = EngMultiByteToWideChar( 00318 (UINT)wCodePage, 00319 (LPWSTR)*ppUnicodeString, 00320 (int)cchUnicodeString * sizeof(WCHAR), 00321 (LPSTR)pAnsiString, 00322 (int)nAnsiChar); 00323 00324 nCharsInUnicodeString = (iCharsInUnicodeString == -1) ? 0 : 00325 (ULONG) iCharsInUnicodeString; 00326 #endif 00327 00328 #else 00329 /* 00330 * Call NLS API (Kernel32) to convert string to Unicode. (User mode) 00331 */ 00332 nCharsInUnicodeString = MultiByteToWideChar( 00333 (UINT)wCodePage, 0, 00334 (LPCSTR)pAnsiString, 00335 (int)nAnsiChar, 00336 (LPWSTR)*ppUnicodeString, 00337 (int)cchUnicodeString); 00338 #endif // _USERK_ 00339 00340 if (nCharsInUnicodeString == 0) { 00341 if (bAllocateMem) { 00342 UserRtlFreeMem(*ppUnicodeString); 00343 } 00344 } 00345 00346 return (int)nCharsInUnicodeString; 00347 } 00348 00349 }

VOID RtlInitLargeAnsiString PLARGE_ANSI_STRING  plstr,
LPCSTR  psz,
UINT  cchLimit
 

Definition at line 608 of file chartran.c.

References _LARGE_ANSI_STRING::bAnsi, _LARGE_ANSI_STRING::Buffer, _LARGE_ANSI_STRING::Length, _LARGE_ANSI_STRING::MaximumLength, min, PLARGE_ANSI_STRING, strlen(), TRUE, and VOID().

Referenced by _CreateWindowEx(), _DefSetText(), MESSAGECALL(), NtUserfnHkINLPCBTCREATESTRUCT(), and xxxCreateWindowEx().

00612 { 00613 ULONG Length; 00614 00615 plstr->Buffer = (PSTR)psz; 00616 plstr->bAnsi = TRUE; 00617 if (ARGUMENT_PRESENT( psz )) { 00618 Length = strlen( psz ); 00619 plstr->Length = min(Length, cchLimit); 00620 plstr->MaximumLength = min((Length + 1), cchLimit); 00621 } else { 00622 plstr->MaximumLength = 0; 00623 plstr->Length = 0; 00624 } 00625 }

VOID RtlInitLargeUnicodeString PLARGE_UNICODE_STRING  plstr,
LPCWSTR  psz,
UINT  cchLimit
 

Definition at line 636 of file chartran.c.

References _LARGE_UNICODE_STRING::bAnsi, _LARGE_UNICODE_STRING::Buffer, FALSE, _LARGE_UNICODE_STRING::Length, _LARGE_UNICODE_STRING::MaximumLength, min, PLARGE_UNICODE_STRING, and VOID().

Referenced by _CreateWindowEx(), _DefSetText(), DlgDirSelectHelper(), DrawSwitchWndHilite(), InternalCreateDialog(), MESSAGECALL(), NtUserfnHkINLPCBTCREATESTRUCT(), SendNotifyMessage(), xxxCreateDefaultImeWindow(), xxxSetFrameTitle(), and xxxSystemParametersInfo().

00640 { 00641 ULONG Length; 00642 00643 plstr->Buffer = (PWSTR)psz; 00644 plstr->bAnsi = FALSE; 00645 if (ARGUMENT_PRESENT( psz )) { 00646 Length = wcslen( psz ) * sizeof( WCHAR ); 00647 plstr->Length = min(Length, cchLimit); 00648 plstr->MaximumLength = min((Length + sizeof(UNICODE_NULL)), cchLimit); 00649 } else { 00650 plstr->MaximumLength = 0; 00651 plstr->Length = 0; 00652 } 00653 }

BOOL RtlMBMessageWParamCharToWCS DWORD  msg,
WPARAM *  pWParam
 

Definition at line 490 of file chartran.c.

References BOOL, CHAR, DWORD, FALSE, IS_ACP, IS_DBCS_ENABLED, MAKE_WPARAM_DBCSCHAR, msg, NT_SUCCESS, NTSTATUS(), NULL, RtlMultiByteToUnicodeN(), Status, THREAD_CODEPAGE, TRUE, and WMCR_IR_DBCSCHAR.

Referenced by CallMsgFilter(), DispatchMessageWorker(), IsDialogMessageA(), MESSAGECALL(), PostMessage(), PostThreadMessage(), SendMessageCallback(), SendMessageWorker(), SendNotifyMessage(), TranslateAcceleratorA(), and xxxDispatchMessage().

00491 { 00492 DWORD dwUni; 00493 NTSTATUS Status; 00494 // FE_SB (RtlMBMessageWParamCharToWCS) 00495 BOOL bWmCrIrDbcsChar = FALSE; 00496 WORD wAnsi = LOWORD(*pWParam); 00497 // end FE_SB (RtlMBMessageWParamCharToWCS) 00498 WORD CodePage = THREAD_CODEPAGE(); 00499 00500 /* 00501 * Only these messages have CHARs: others are passed through 00502 */ 00503 00504 switch(msg) { 00505 // FE_SB (RtlMBMessageWParamCharToWCS) 00506 case WM_CHAR: 00507 // 00508 // WM_CHAR's wParam format for WM_IME_REPORT:IR_DBCSCHAR 00509 // 00510 if (IS_DBCS_ENABLED() && (*pWParam & WMCR_IR_DBCSCHAR)) { 00511 // 00512 // Mark this message is sent as IR_DBCSCHAR format. 00513 // 00514 bWmCrIrDbcsChar = TRUE; 00515 } 00516 00517 // 00518 // Fall through.... 00519 // 00520 #ifdef FE_IME 00521 case WM_IME_CHAR: 00522 case WM_IME_COMPOSITION: 00523 // 00524 // We need to re-align for Unicode convertsion.. 00525 // WM_CHAR/WM_IME_CHAR/WM_IME_COMPOSITION's wParam format : 00526 // 00527 // ReAlign IR_DBCS char format to regular sequence. 00528 // 00529 // From: 00530 // 00531 // HIWORD(wParam) = 0; 00532 // HIBYTE(LOWORD(wParam)) = DBCS LeadingByte. 00533 // LOBYTE(LOWORD(wParan)) = DBCS TrailingByte or SBCS character. 00534 // 00535 // To: 00536 // HIWORD(wParam) = 0; 00537 // HIBYTE(LOWORD(wParam)) = DBCS TrailingByte. 00538 // LOBYTE(LOWORD(wParam)) = DBCS LeadingByte or SBCS character. 00539 // 00540 if (IS_DBCS_ENABLED()) { 00541 *pWParam = MAKE_WPARAM_DBCSCHAR(wAnsi); 00542 } 00543 #endif 00544 // 00545 // Fall through... 00546 // 00547 // end FE_SB (RtlMBMessageWParamCharToWCS) 00548 case WM_CHARTOITEM: 00549 case EM_SETPASSWORDCHAR: 00550 case WM_DEADCHAR: 00551 case WM_SYSCHAR: 00552 case WM_SYSDEADCHAR: 00553 case WM_MENUCHAR: 00554 00555 dwUni = 0; 00556 00557 if (IS_ACP(CodePage)) { 00558 Status = RtlMultiByteToUnicodeN((LPWSTR)&dwUni, sizeof(dwUni), 00559 NULL, (LPSTR)pWParam, 2 * sizeof(CHAR)); 00560 if (!NT_SUCCESS(Status)) 00561 return FALSE; 00562 } else { 00563 int cwch; 00564 #ifdef _USERK_ 00565 cwch = EngMultiByteToWideChar(CodePage, 00566 (LPWSTR)&dwUni, sizeof(dwUni), 00567 (LPSTR)pWParam, 2); 00568 #else 00569 cwch = MultiByteToWideChar(CodePage, 0, 00570 (LPSTR)pWParam, 2, 00571 (LPWSTR)&dwUni, sizeof(dwUni) / sizeof(WCHAR)); 00572 #endif // _USERK_ 00573 // KdPrint(("0x%02x -> 0x%04x (%d)\n", *pWParam, dwUni, CodePage)); 00574 if (cwch == 0) { 00575 return FALSE; 00576 } 00577 } 00578 00579 // FE_SB (RtlMBMessageWParamCharToWCS) 00580 // 00581 // if this character is sent for WM_IME_REPORT:IR_DBCSCHAR, we mark it. 00582 // 00583 if (bWmCrIrDbcsChar) 00584 dwUni |= WMCR_IR_DBCSCHAR; 00585 // else FE_SB (RtlMBMessageWParamCharToWCS) 00586 #if DBG 00587 if ((dwUni == 0) || (dwUni > 0xFF)) { 00588 RIPMSG1(RIP_VERBOSE, "msgA -> msgW: wchar = 0x%lX\n", dwUni); 00589 } 00590 #endif 00591 // end FE_SB 00592 *pWParam = dwUni; 00593 break; 00594 } 00595 00596 return TRUE; 00597 }

BOOL RtlWCSMessageWParamCharToMB DWORD  msg,
WPARAM *  pWParam
 

Definition at line 361 of file chartran.c.

References BOOL, DWORD, HIBYTE, IS_ACP, IS_DBCS_ENABLED, IS_DBCS_MESSAGE, LOBYTE, msg, NT_SUCCESS, NTSTATUS(), NULL, RtlUnicodeToMultiByteN(), Status, THREAD_CODEPAGE, and TRUE.

Referenced by _PeekMessage(), DispatchMessageWorker(), GetMessage(), SendMessageWorker(), and xxxDispatchMessage().

00362 { 00363 DWORD dwAnsi; 00364 NTSTATUS Status; 00365 WORD CodePage; 00366 int nbWch; 00367 00368 #ifdef FE_SB // RtlWCSMessageWParamCharToMB() 00369 // 00370 // Format of *pWParam here... 00371 // 00372 // LOWORD(*pWParam) = Unicode CodePoint... 00373 // HIWORD(*pWParam) = Has some information for DBCS messaging 00374 // (ex. WPARAM_IR_DBCSCHAR) 00375 // 00376 // Then we need to convert ONLY loword of wParam to Unicode... 00377 // 00378 #endif // FE_SB 00379 #ifndef FE_SB 00380 // NtBug #3135 (Closed 02/04/93) 00381 // Publisher Posts WM_CHAR messages with wParam > 0xFF (not a valid ANSI char)! 00382 // 00383 // It does this to disable TranslateAccelerator for that char. 00384 // MSPub's winproc must get the non-ANSI 'character' value, so PostMessage must 00385 // translate *two* characters of wParam for character messages, and PeekMessage 00386 // must translate *two* Unicode chars of wParam for ANSI app. 00387 #endif 00388 00389 /* 00390 * Only these messages have CHARs: others are passed through 00391 */ 00392 00393 switch(msg) { 00394 #ifdef FE_IME // RtlWCSMessageWParamCharToMB() 00395 case WM_IME_CHAR: 00396 case WM_IME_COMPOSITION: 00397 #endif // FE_IME 00398 case WM_CHAR: 00399 case WM_CHARTOITEM: 00400 case EM_SETPASSWORDCHAR: 00401 case WM_DEADCHAR: 00402 case WM_SYSCHAR: 00403 case WM_SYSDEADCHAR: 00404 case WM_MENUCHAR: 00405 00406 CodePage = THREAD_CODEPAGE(); 00407 dwAnsi = 0; 00408 00409 nbWch = IS_DBCS_ENABLED() ? 1 * sizeof(WCHAR) : 2 * sizeof(WCHAR); 00410 00411 if (IS_ACP(CodePage)) { 00412 // HACK HACK HACK HACK (for NtBug #3135) 00413 // to allow applications that store data in high word of wParam 00414 // Jan/06/96 hiroyama 00415 Status = RtlUnicodeToMultiByteN((LPSTR)&dwAnsi, sizeof(dwAnsi), 00416 NULL, (LPWSTR)pWParam, nbWch); 00417 if (!NT_SUCCESS(Status)) { 00418 // LATER IanJa: returning FALSE makes GetMessage fail, which 00419 // terminates the app. We should use some default 'bad character' 00420 // I use 0x00 for now. 00421 *pWParam = 0x00; 00422 return TRUE; 00423 } 00424 } else { 00425 int cwch; 00426 // assuming little endian 00427 #ifdef _USERK_ 00428 cwch = EngWideCharToMultiByte(CodePage, 00429 (LPWSTR)pWParam, nbWch, 00430 (LPSTR)&dwAnsi, sizeof(dwAnsi)); 00431 #else 00432 cwch = WideCharToMultiByte(CodePage, 0, 00433 (LPCWSTR)pWParam, nbWch / sizeof(WCHAR), 00434 (LPSTR)&dwAnsi, sizeof(dwAnsi), NULL, NULL); 00435 #endif // _USERK_ 00436 // KdPrint(("0x%04x -> 0x%02x (%d)\n", *pWParam, dwAnsi, CodePage)); 00437 if (cwch == 0) { 00438 *pWParam = 0x00; 00439 return TRUE; 00440 } 00441 } 00442 if (IS_DBCS_ENABLED()) { 00443 WORD wAnsi = LOWORD(dwAnsi); 00444 // 00445 // From: 00446 // HIBYTE(wAnsi) = Dbcs TrailingByte. 00447 // LOBYTE(wAnsi) = Dbcs LeadingByte or Sbcs character. 00448 // 00449 // To: 00450 // HIWORD(*pWParam) = Original Data (information for DBCS messgaing). 00451 // HIBYTE(LOWORD(*pWParam)) = Dbcs LeadingByte Byte. 00452 // LOBYTE(LOWORD(*pWParam)) = Dbcs TrailingByte or Sbcs character. 00453 // 00454 if (IS_DBCS_MESSAGE(wAnsi)) { 00455 // 00456 // It's a DBCS character. 00457 // 00458 *pWParam = MAKEWPARAM(MAKEWORD(HIBYTE(wAnsi),LOBYTE(wAnsi)),HIWORD(*pWParam)); 00459 } else { 00460 // 00461 // It's a SBCS character. 00462 // 00463 *pWParam = MAKEWPARAM(MAKEWORD(LOBYTE(wAnsi),0),0); 00464 } 00465 } else { 00466 #if DBG 00467 if ((dwAnsi == 0) || (dwAnsi > 0xFF)) { 00468 RIPMSG1(RIP_VERBOSE, "msgW -> msgA: char = 0x%.4lX\n", dwAnsi); 00469 } 00470 #endif 00471 *pWParam = dwAnsi; 00472 } 00473 break; 00474 } 00475 00476 return TRUE; 00477 }


Generated on Sat May 15 19:43:03 2004 for test by doxygen 1.3.7