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

kcodecnv.c File Reference

#include "precomp.h"

Go to the source code of this file.

Classes

struct  tagHIGH_LOW
union  tagWANSUNG

Defines

#define IDD_2BEOL   100
#define IDD_3BEOL1   101
#define IDD_3BEOL2   102
#define lpSource(lpks)   (LPSTR)((LPSTR)lpks+lpks->dchSource)
#define lpDest(lpks)   (LPSTR)((LPSTR)lpks+lpks->dchDest)
#define JOHAB_CP   1361
#define WANSUNG_CP   949
#define TWO_BYTE   2
#define ONE_WORD   1

Typedefs

typedef tagHIGH_LOW HIGH_LOW
typedef tagWANSUNG WANSUNG

Functions

WORD JunjaToBanja (LPSTR lpSrc, LPSTR lpDest)
WORD BanjaToJunja (LPSTR lpSrc, LPSTR lpDest)
WORD JohabToKs (LPSTR lpSrc, LPSTR lpDest)
WORD KsToJohab (LPSTR lpSrc, LPSTR lpDest)
LRESULT TransCodeConvert (HIMC hIMC, LPIMESTRUCT lpIme)
LRESULT TransConvertList (HIMC hImc, LPIMESTRUCT lpIme)
LRESULT TransGetMNTable (HIMC hImc, LPIMESTRUCT lpIme)

Variables

CONST WORD HMNTable [3][96]
CONST WORD wKSCompCode [51]
CONST WORD wKSCompCode2 [30]


Define Documentation

#define IDD_2BEOL   100
 

Definition at line 16 of file kcodecnv.c.

Referenced by TransGetMNTable().

#define IDD_3BEOL1   101
 

Definition at line 17 of file kcodecnv.c.

#define IDD_3BEOL2   102
 

Definition at line 18 of file kcodecnv.c.

#define JOHAB_CP   1361
 

Definition at line 23 of file kcodecnv.c.

Referenced by JohabToKs(), and KsToJohab().

#define lpDest lpks   )     (LPSTR)((LPSTR)lpks+lpks->dchDest)
 

Definition at line 21 of file kcodecnv.c.

Referenced by AddEllipsisAndDrawLine(), BanjaToJunja(), ECDoIMEMenuCommand(), EcImeRequestHandler(), JohabToKs(), JunjaToBanja(), KsToJohab(), TransCodeConvert(), TransConvertList(), WriteAscii85(), and WriteASCII85Cont().

#define lpSource lpks   )     (LPSTR)((LPSTR)lpks+lpks->dchSource)
 

Definition at line 20 of file kcodecnv.c.

Referenced by CString::LoadAndFormat(), TransCodeConvert(), TransConvertList(), and WriteASCII85Cont().

#define ONE_WORD   1
 

Definition at line 26 of file kcodecnv.c.

Referenced by JohabToKs(), and KsToJohab().

#define TWO_BYTE   2
 

Definition at line 25 of file kcodecnv.c.

Referenced by JohabToKs(), and KsToJohab().

#define WANSUNG_CP   949
 

Definition at line 24 of file kcodecnv.c.

Referenced by JohabToKs(), and KsToJohab().


Typedef Documentation

typedef struct tagHIGH_LOW HIGH_LOW
 

typedef union tagWANSUNG WANSUNG
 


Function Documentation

WORD BanjaToJunja LPSTR  lpSrc,
LPSTR  lpDest
 

Definition at line 415 of file kcodecnv.c.

References BYTE, and lpDest.

Referenced by TransCodeConvert().

00422 : 00423 00424 Arguments: 00425 00426 Return Value: 00427 00428 --*/ 00429 00430 { 00431 WORD wCount = 0; 00432 00433 while (*lpSrc) 00434 { 00435 if ((BYTE)(*lpSrc) < (BYTE)0x80) 00436 { 00437 if (*lpSrc++ == ' ') 00438 { 00439 *lpDest++ = (BYTE)0xA1; 00440 *lpDest++ = (BYTE)0xA1; 00441 wCount += 2; 00442 } 00443 else 00444 { 00445 *lpDest++ = (BYTE)0xA3; 00446 *lpDest++ = *(lpSrc - 1) + (BYTE)0x80; 00447 wCount += 2; 00448 } 00449 } 00450 else 00451 { 00452 *lpDest++ = *lpSrc++; 00453 *lpDest++ = *lpSrc++; 00454 wCount += 2; 00455 } 00456 } 00457 *lpDest = '\0'; 00458 return (wCount); 00459 }

WORD JohabToKs LPSTR  lpSrc,
LPSTR  lpDest
 

Definition at line 462 of file kcodecnv.c.

References BYTE, CHAR, tagWANSUNG::e, tagHIGH_LOW::high, JOHAB_CP, tagHIGH_LOW::low, lpDest, NULL, ONE_WORD, TWO_BYTE, tagWANSUNG::w, WANSUNG_CP, wKSCompCode, and wKSCompCode2.

Referenced by TransCodeConvert().

00469 : 00470 00471 Arguments: 00472 00473 Return Value: 00474 00475 --*/ 00476 00477 { 00478 WORD wCount = 0; 00479 #if defined(OLD_CONV) 00480 WANSUNG wsSCode, wsDCode; 00481 int iHead = 0, iTail = 2349, iMid; 00482 BYTE bCount; 00483 #endif 00484 00485 while (*lpSrc) 00486 { 00487 if ((BYTE)(*lpSrc) < (BYTE)0x80) 00488 { 00489 *lpDest++ = *lpSrc++; 00490 wCount++; 00491 } 00492 else 00493 #if defined(OLD_CONV) 00494 { 00495 wsSCode.e.high = *lpSrc++; 00496 wsSCode.e.low = *lpSrc++; 00497 for (bCount = 0; bCount < 51 && wKSCompCode[bCount] != wsSCode.w; bCount++) 00498 ; 00499 wsDCode.w = (bCount == 51)? 0: bCount + 0xA4A1; 00500 if (wsDCode.w) 00501 { 00502 *lpDest++ = wsDCode.e.high; 00503 *lpDest++ = wsDCode.e.low; 00504 wCount += 2; 00505 continue; 00506 } 00507 for (bCount = 0; bCount < 30 && wKSCompCode2[bCount] != wsSCode.w; bCount++) 00508 ; 00509 wsDCode.w = (bCount == 30)? 0: bCount + 0xA4A1; 00510 if (wsDCode.w) 00511 { 00512 *lpDest++ = wsDCode.e.high; 00513 *lpDest++ = wsDCode.e.low; 00514 wCount += 2; 00515 continue; 00516 } 00517 while (iHead <= iTail && !wsDCode.w) 00518 { 00519 iMid = (iHead + iTail) / 2; 00520 if (wKSCharCode[iMid] > wsSCode.w) 00521 iTail = iMid - 1; 00522 else if (wKSCharCode[iMid] < wsSCode.w) 00523 iHead = iMid + 1; 00524 else 00525 wsDCode.w = ((iMid / 94 + 0xB0) << 8) | (iMid % 94 + 0xA1); 00526 } 00527 if (wsDCode.w) 00528 { 00529 *lpDest++ = wsDCode.e.high; 00530 *lpDest++ = wsDCode.e.low; 00531 wCount += 2; 00532 } 00533 else 00534 { 00535 *lpDest++ = wsSCode.e.high; 00536 *lpDest++ = wsSCode.e.low; 00537 wCount += 2; 00538 } 00539 } 00540 #else 00541 { 00542 // for simple implementation, converting one character by character 00543 // we have to change it string to string conversion. 00544 WCHAR wUni; 00545 CHAR chTmp[2]; 00546 00547 chTmp[0] = *lpSrc++; 00548 chTmp[1] = *lpSrc++; 00549 00550 MultiByteToWideChar(JOHAB_CP, MB_PRECOMPOSED, chTmp, TWO_BYTE, &wUni, ONE_WORD); 00551 00552 WideCharToMultiByte(WANSUNG_CP, 0, &wUni, ONE_WORD, chTmp, TWO_BYTE, NULL, NULL); 00553 00554 *lpDest++ = chTmp[0]; 00555 *lpDest++ = chTmp[1]; 00556 00557 wCount += 2; 00558 } 00559 #endif 00560 } 00561 *lpDest = '\0'; 00562 return (wCount); 00563 }

WORD JunjaToBanja LPSTR  lpSrc,
LPSTR  lpDest
 

Definition at line 362 of file kcodecnv.c.

References BYTE, tagWANSUNG::e, tagHIGH_LOW::high, tagHIGH_LOW::low, lpDest, and tagWANSUNG::w.

Referenced by TransCodeConvert().

00369 : 00370 00371 Arguments: 00372 00373 Return Value: 00374 00375 --*/ 00376 00377 { 00378 WANSUNG wsCode; 00379 WORD wCount = 0; 00380 00381 while (*lpSrc) 00382 { 00383 if ((BYTE)(*lpSrc) < (BYTE)0x80) 00384 { 00385 *lpDest++ = *lpSrc++; 00386 wCount++; 00387 } 00388 else 00389 { 00390 wsCode.e.high = *lpSrc++; 00391 wsCode.e.low = *lpSrc++; 00392 if (wsCode.w == 0xA1A1) 00393 { 00394 *lpDest++ = ' '; 00395 wCount++; 00396 } 00397 else if (wsCode.w >= 0xA3A1 && wsCode.w <= 0xA3FE) 00398 { 00399 *lpDest++ = wsCode.e.low - (BYTE)0x80; 00400 wCount++; 00401 } 00402 else 00403 { 00404 *lpDest++ = wsCode.e.high; 00405 *lpDest++ = wsCode.e.low; 00406 wCount += 2; 00407 } 00408 } 00409 } 00410 *lpDest = '\0'; 00411 return (wCount); 00412 }

WORD KsToJohab LPSTR  lpSrc,
LPSTR  lpDest
 

Definition at line 566 of file kcodecnv.c.

References BYTE, CHAR, tagWANSUNG::e, tagHIGH_LOW::high, JOHAB_CP, tagHIGH_LOW::low, lpDest, NULL, ONE_WORD, TWO_BYTE, tagWANSUNG::w, WANSUNG_CP, and wKSCompCode.

Referenced by TransCodeConvert().

00573 : 00574 00575 Arguments: 00576 00577 Return Value: 00578 00579 --*/ 00580 00581 { 00582 #if defined(OLD_CONV) 00583 WANSUNG wsSCode, wsDCode; 00584 WORD wCount = 0, wLoc; 00585 #else 00586 WORD wCount = 0; 00587 #endif 00588 00589 while (*lpSrc) 00590 { 00591 if ((BYTE)(*lpSrc) < (BYTE)0x80) 00592 { 00593 *lpDest++ = *lpSrc++; 00594 wCount++; 00595 } 00596 else 00597 #if defined(OLD_CONV) 00598 { 00599 wsSCode.e.high = *lpSrc++; 00600 wsSCode.e.low = *lpSrc++; 00601 if (wsSCode.w >= (WORD)0xA4A1 && wsSCode.w <= (WORD)0xA4D3) 00602 { 00603 wsDCode.w = wKSCompCode[wsSCode.w - 0xA4A1]; 00604 *lpDest++ = wsDCode.e.high; 00605 *lpDest++ = wsDCode.e.low; 00606 } 00607 else if (wsSCode.w >= (WORD)0xB0A1 && wsSCode.w <= (WORD)0xC8FE 00608 && wsSCode.e.low != (BYTE)0xFF) 00609 { 00610 wLoc = (wsSCode.e.high - 176) * 94; 00611 wLoc += wsSCode.e.low - 161; 00612 wsDCode.w = wKSCharCode[wLoc]; 00613 *lpDest++ = wsDCode.e.high; 00614 *lpDest++ = wsDCode.e.low; 00615 } 00616 else 00617 { 00618 *lpDest++ = wsSCode.e.high; 00619 *lpDest++ = wsSCode.e.low; 00620 } 00621 wCount += 2; 00622 } 00623 #else 00624 { 00625 WCHAR wUni; 00626 CHAR chTmp[2]; 00627 00628 chTmp[0] = *lpSrc++; 00629 chTmp[1] = *lpSrc++; 00630 00631 MultiByteToWideChar(WANSUNG_CP, MB_PRECOMPOSED, chTmp, TWO_BYTE, &wUni, ONE_WORD); 00632 00633 WideCharToMultiByte(JOHAB_CP, 0, &wUni, ONE_WORD, chTmp, TWO_BYTE, NULL, NULL); 00634 00635 *lpDest++ = chTmp[0]; 00636 *lpDest++ = chTmp[1]; 00637 00638 wCount += 2; 00639 } 00640 #endif 00641 } 00642 *lpDest = '\0'; 00643 return (wCount); 00644 }

LRESULT TransCodeConvert HIMC  hIMC,
LPIMESTRUCT  lpIme
 

Definition at line 647 of file kcodecnv.c.

References BanjaToJunja(), JohabToKs(), JunjaToBanja(), KsToJohab(), lpDest, and lpSource.

Referenced by TranslateIMESubFunctions().

00654 : 00655 00656 Arguments: 00657 00658 Return Value: 00659 00660 --*/ 00661 00662 { 00663 UNREFERENCED_PARAMETER(hIMC); 00664 00665 switch (lpIme->wParam) 00666 { 00667 case IME_JUNJAtoBANJA: 00668 lpIme->wCount = JunjaToBanja(lpSource(lpIme), lpDest(lpIme)); 00669 break; 00670 00671 case IME_BANJAtoJUNJA: 00672 lpIme->wCount = BanjaToJunja(lpSource(lpIme), lpDest(lpIme)); 00673 break; 00674 00675 case IME_JOHABtoKS: 00676 lpIme->wCount = JohabToKs(lpSource(lpIme), lpDest(lpIme)); 00677 break; 00678 00679 case IME_KStoJOHAB: 00680 lpIme->wCount = KsToJohab(lpSource(lpIme), lpDest(lpIme)); 00681 break; 00682 00683 default: 00684 lpIme->wCount = 0; 00685 } 00686 return (lpIme->wCount); 00687 }

LRESULT TransConvertList HIMC  hImc,
LPIMESTRUCT  lpIme
 

Definition at line 689 of file kcodecnv.c.

References GetKeyboardLayout(), ImmGetConversionListA(), lpDest, lpSource, NULL, and UINT.

Referenced by TranslateIMESubFunctions().

00690 { 00691 LPSTR lpSrc; 00692 LPSTR lpDst; 00693 HGLOBAL hCandList; 00694 LPCANDIDATELIST lpCandList; 00695 LPSTR lpCandStr; 00696 UINT i, uBufLen; 00697 LRESULT lRet = 0; 00698 00699 lpSrc = lpSource(lpIme); 00700 lpDst = lpDest(lpIme); 00701 uBufLen = ImmGetConversionListA(GetKeyboardLayout(0), hImc, (LPCSTR)lpSrc, 00702 NULL, 0, GCL_CONVERSION); 00703 if (uBufLen) 00704 { 00705 hCandList = GlobalAlloc(GHND, uBufLen); 00706 lpCandList = (LPCANDIDATELIST)GlobalLock(hCandList); 00707 lRet = ImmGetConversionListA(GetKeyboardLayout(0), hImc, (LPCSTR)lpSrc, 00708 lpCandList, uBufLen, GCL_CONVERSION); 00709 for (i = 0; i < lpCandList->dwCount; i++) 00710 { 00711 lpCandStr = (LPSTR)lpCandList + lpCandList->dwOffset[i]; 00712 *lpDst++ = *lpCandStr++; 00713 *lpDst++ = *lpCandStr++; 00714 } 00715 *lpDst = '\0'; 00716 lpIme->wCount = (WORD)lpCandList->dwCount * 2; 00717 GlobalUnlock(hCandList); 00718 GlobalFree(hCandList); 00719 } 00720 return (lRet); 00721 }

LRESULT TransGetMNTable HIMC  hImc,
LPIMESTRUCT  lpIme
 

Definition at line 723 of file kcodecnv.c.

References HIBYTE, HMNTable, IDD_2BEOL, L, LOBYTE, and TRUE.

Referenced by TranslateIMESubFunctions().

00724 { 00725 LPSTR lpMnemonic; 00726 int iCount, iCIM; 00727 00728 UNREFERENCED_PARAMETER(hImc); 00729 00730 lpMnemonic = (LPSTR)(lpIme->lParam1); 00731 // BUGBUG: Will be changed to use Registry instead of WIN.INI 00732 iCIM = GetProfileInt(L"WANSUNG", L"InputMethod", IDD_2BEOL) - IDD_2BEOL; 00733 for (iCount = 0; iCount < 96; iCount++, lpMnemonic += 2) 00734 { 00735 *lpMnemonic = LOBYTE(HMNTable[iCIM][iCount]); 00736 *(lpMnemonic+1) = HIBYTE(HMNTable[iCIM][iCount]); 00737 } 00738 return TRUE; 00739 }


Variable Documentation

CONST WORD HMNTable[3][96]
 

Definition at line 40 of file kcodecnv.c.

Referenced by TransGetMNTable().

CONST WORD wKSCompCode[51]
 

Initial value:

{ 0x8841,0x8C41,0x8444,0x9041,0x8446,0x8447,0x9441,0x9841,0x9C41,0x844A, 0x844B,0x844C,0x844D,0x844E,0x844F,0x8450,0xA041,0xA441,0xA841,0x8454, 0xAC41,0xB041,0xB441,0xB841,0xBC41,0xC041,0xC441,0xC841,0xCC41,0xD041, 0x8461,0x8481,0x84A1,0x84C1,0x84E1,0x8541,0x8561,0x8581,0x85A1,0x85C1, 0x85E1,0x8641,0x8661,0x8681,0x86A1,0x86C1,0x86E1,0x8741,0x8761,0x8781, 0x87A1 }

Definition at line 343 of file kcodecnv.c.

Referenced by JohabToKs(), and KsToJohab().

CONST WORD wKSCompCode2[30]
 

Initial value:

{ 0x8442,0x8443,0x8444,0x8445,0x8446,0x8447,0x8448,0x9841,0x8449,0x844A, 0x844B,0x844C,0x844D,0x844E,0x844F,0x8450,0x8451,0x8453,0xA841,0x8454, 0x8455,0x8456,0x8457,0x8458,0xBC41,0x8459,0x845A,0x845B,0x845C,0x845D }

Definition at line 353 of file kcodecnv.c.

Referenced by JohabToKs().


Generated on Sat May 15 19:44:24 2004 for test by doxygen 1.3.7