Back to index

im-sdk  12.3.91
Functions | Variables
PyBasic.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "GeneType.h"
#include "PyBasic.h"

Go to the source code of this file.

Functions

JINT GbkHz2244ToYj (JINT nHzcode)
JINT GbkHz2244ToYjSM (JINT nHzcode)
JINT GetDyzInfo (JINT nHzcode, JINT *pnDyzYjCode)
JINT EncodeDyzTo2244 (JINT nHzcode, JINT nYjcode)
JINT FastMatchYinJieStr (CHAR *szPystr)
UCHARRecovDyz2244 (UCHAR *szDyz2244)
JWORD RecovDyzWord2244 (JWORD wDyz2244)
JWORDRecovDyzNWord2244 (JWORD *pwDyz2244, JINT nMaxLen)
CHAR LastChar (JINT nYinjieCode)
CHAR FirstChar (JINT nYinjieCode)
JINT ValidButLastChar (JINT nYinjieCode)
JINT ValidButFirstChar (JINT nYinjieCode)
JINT ValidAddChar (CHAR ch, JINT nYinjieCode)
VOID UnifOrgSpStr (CHAR *pszOrgSp, CHAR *pszUnifSp)
JINT Sp2QpStr (CHAR *pszOrgSp, CHAR *pszUnifSp, CHAR *pszQp, JINT nKeyLayMode)
JINT Sp2QpStr_Better (CHAR *pszOrgSp, CHAR *pszQp, JINT nKeyLayMode, JINT nSpCaretPos, JINT *pnQpCaretPos)
JINT IsValidSpSuite (CHAR chSM, CHAR chYM, JINT nKeyLayMode)
JINT TypeOfSpChar (CHAR *pszOrgSp, JINT nPos, JINT nKeyLayMode)
JINT IsLower (CHAR ch)
JINT IsUpper (CHAR ch)
CHAR Lower (CHAR ch)
CHAR Upper (CHAR ch)

Variables

CHAR szLocale [10]
CHARSHENGMUSTR [26]
JINT INDEXSMTOYINJIE [27]
JINT INDEXMAGIC [26]
CHARYUNMUSTR [37]
JINT KEYLAYMODE [3][27]
CHARYINJIESTR [NUM_YINJIE+1]
JINT DYZLIST [TOTAL_DYZYINJIE]
JINT DYZYJCODE [TOTAL_DYZYINJIE]
JINT INDEXOFDYZLIST [DISTOF_B0_F7+1]
CHARYINJIESTR_CSZ [NUM_YINJIE+1]
JUINT GBHZCODETOYJ []
JUINT GBKHZCODETOYJ []
JUINT DYZCODETOYJ []
UCHAR HIFREQHANZI [26][14]
UCHAR NONLINKHZ [2 *NUM_NONLINKHZ+2] = "是的了不也而你我他与它她其就和或"
UCHAR PRELINKHZ [2 *NUM_PRELINKHZ+2] = "们性员子上下中内外化者家儿年月日时分秒街路村"
UCHAR SUFLINKHZ [2 *NUM_SUFLINKHZ+2] = "不在这从到那哪第各每某本总当由如以为被使更且指于但将可应会该此全很都近约"

Function Documentation

JINT EncodeDyzTo2244 ( JINT  nHzcode,
JINT  nYjcode 
)

Definition at line 1769 of file PyBasic.c.

{
       JINT    nHiHzPos, nLowHz;
       JINT    i;
       
       nHiHzPos = ((nHzcode & 0xFF00) >> 8) - 0xB0;
       if ((nHiHzPos < 0) || (nHiHzPos > (0xF7 - 0xB0)))
              return 0xFFFF;

       nLowHz = nHzcode & 0x00FF;
       
       for (i = INDEXOFDYZLIST[nHiHzPos]; i < INDEXOFDYZLIST[nHiHzPos + 1]; i++)
       {
              if ( ((DYZLIST[i] & 0x00FF) == nLowHz) && (DYZYJCODE[i] == nYjcode) )
                     return (i + 0x2001);
       }
       
       return 0xFFFF;
}

Here is the caller graph for this function:

JINT FastMatchYinJieStr ( CHAR szPystr)

Definition at line 1794 of file PyBasic.c.

{
       JINT    i, j, nLen;
       CHAR    chFirst;
       JINT    nFromYJStr, nToYJStr, nShengmuIndex;     
       
       i = 0;
       nLen = (JINT)strlen(szPystr);
       
       j = 0;
       if (nLen > 0)
       {
              chFirst    = szPystr[0];
              nFromYJStr = INDEXSMTOYINJIE[ INDEXMAGIC[(JINT)(chFirst - 'a')] ];
              nToYJStr   = INDEXSMTOYINJIE[ INDEXMAGIC[(JINT)(chFirst - 'a')] + 1];
              nShengmuIndex = INDEXMAGIC[(JINT)(chFirst - 'a')];
              
              if ((chFirst == 'c') && (nLen > 1) && (szPystr[1] == 'h'))
              {
                     nFromYJStr = INDEXSMTOYINJIE[3];
                     nToYJStr   = INDEXSMTOYINJIE[4];
                     nShengmuIndex = 3;
              }
              else if ((chFirst == 's') && (nLen > 1) && (szPystr[1] == 'h'))
              {
                     nFromYJStr = INDEXSMTOYINJIE[19];
                     nToYJStr   = INDEXSMTOYINJIE[20];
                     nShengmuIndex = 19;
              }
              else if ((chFirst == 'z') && (nLen > 1) && (szPystr[1] == 'h'))
              {
                     nFromYJStr = INDEXSMTOYINJIE[25];
                     nToYJStr   = INDEXSMTOYINJIE[26];
                     nShengmuIndex = 25;
              }

              i = nFromYJStr;
              do {
                     j = strcmp (YINJIESTR_CSZ[i], szPystr);
                     i++;
              } while ((i < nToYJStr) && (j != 0));
       }
       
       if (j == 0)
              return (i - 1);
       else
              return (-1);
}

Here is the caller graph for this function:

CHAR FirstChar ( JINT  nYinjieCode)

Definition at line 1866 of file PyBasic.c.

{
       CHAR   res = ' ';           /* SPACE */
       
       if ((nYinjieCode >= 0) && (nYinjieCode <= 414))
              res = YINJIESTR_CSZ[nYinjieCode][0];
       return res;
}

Here is the caller graph for this function:

JINT GbkHz2244ToYj ( JINT  nHzcode)

Definition at line 1640 of file PyBasic.c.

{
       JINT    hi, low;
       JINT    res;
       JINT    t1, t2, t3, t4;
       
       hi  = (nHzcode >> 8) & 0x00FF;
       low = nHzcode & 0x00FF;
       t1  = t2 = t3 = t4 = 0;
       
       res = 0xFFFF;
       if ((hi >= 0x81) && (hi <= 0xA0) && (low >= 0x40) && (low <= 0xFE))
       {
              t1 = (hi - 0x81) * 191 + (low - 0x40) + 1;
              t2 = (t1 * 9 - 1) / 32;
              t3 = ((t1 - 1) * 9 - 1) / 32;
              t4 = (t1 * 9) % 32;

              if (t2 > t3)
                     res = (JINT)( (GBKHZCODETOYJ[t2] >> (32 - t4)) & 0x01FF ) + 
                           (JINT)( (GBKHZCODETOYJ[t3] << t4) & 0x01FF );
              else if (t2 == t3)
                     res = (JINT)( GBKHZCODETOYJ[t2] >> (32 - t4) ) & 0x01FF;
       }
       else if ((hi >= 0xAA) && (hi <= 0xFE) && (low >= 0x40) && (low <= 0xFE))
       {
              t1 = (hi - 0xAA) * 191 + (low - 0x40) + 1;
              t2 = (t1 * 9 - 1) / 32;
              t3 = ((t1 - 1) * 9 - 1) / 32;
              t4 = (t1 * 9) % 32;

              if (t2 > t3)
                     res = (JINT)( (GBKHZCODETOYJ[t2 + (9 * 191)] >> (32 - t4)) & 0x01FF ) + 
                           (JINT)( (GBKHZCODETOYJ[t3 + (9 * 191)] << t4) & 0x01FF );
              else if (t2 == t3)
                     res = (JINT)( GBKHZCODETOYJ[t2 + (9 * 191)] >> (32 - t4) ) & 0x01FF;
       }
       else if ((nHzcode >= 0x2001) && (nHzcode <= 0x2244))
       {
              t1 = nHzcode - 0x2000;
              t2 = (t1 * 9 - 1) / 32;
              t3 = ((t1 - 1) * 9 - 1) / 32;
              t4 = (t1 * 9) % 32;
                     
              if (t2 > t3)
                     res = (JINT)( (DYZCODETOYJ[t2] >> (32 - t4)) & 0x01FF ) + 
                           (JINT)( (DYZCODETOYJ[t3] << t4) & 0x01FF );
              else if (t2 == t3)
                     res = (JINT)( DYZCODETOYJ[t2] >> (32 - t4) ) & 0x01FF;
       }
       else
              res = 0xFFFF;

       if (res == 0x01FF)
              res = 0xFFFF;
              
       return (res);
}
JINT GbkHz2244ToYjSM ( JINT  nHzcode)

Definition at line 1706 of file PyBasic.c.

{
       JINT    nTmpRes;
       JINT    nRet;
       
       nTmpRes = GbkHz2244ToYj(nHzcode);

       if (nTmpRes != 0xFFFF)
       {
              if ((nTmpRes >= 38) && (nTmpRes < 57 ))        /* "ch" */
                     nRet =  3 + 450;
              else if ((nTmpRes >= 301) && (nTmpRes < 320))  /* "sh" */
                     nRet = 19 + 450;
              else if ((nTmpRes >= 395) && (nTmpRes < 415))  /* "zh" */
                     nRet = 25 + 450;
              else
                     nRet = INDEXMAGIC[(JINT)(YINJIESTR_CSZ[nTmpRes][0] - 'a')] + 450;
                     
              return nRet;
       }

       return 0xFFFF;
}
JINT GetDyzInfo ( JINT  nHzcode,
JINT pnDyzYjCode 
)

Definition at line 1739 of file PyBasic.c.

{
       JINT    nHiHzPos, nLowHz;
       JINT    i, j;
       
       nHiHzPos = ((nHzcode & 0xFF00) >> 8) - 0xB0;
       nLowHz   = nHzcode & 0x00FF;
       
       j = 0;
       if ((nHiHzPos < 0) || (nHiHzPos > (0xF7 - 0xB0)))
              return j;

       for (i = INDEXOFDYZLIST[nHiHzPos]; i < INDEXOFDYZLIST[nHiHzPos + 1]; i++)
       {
              if( (DYZLIST[i] & 0x00FF) == nLowHz )
              {
                     pnDyzYjCode[j] = DYZYJCODE[i];
                     j++;
              }
       }
       return j;
}

Here is the caller graph for this function:

JINT IsLower ( CHAR  ch)

Definition at line 2416 of file PyBasic.c.

{
       if ((ch >= 'a') && (ch <= 'z'))
              return TRUE;
              
       return FALSE;
}
JINT IsUpper ( CHAR  ch)

Definition at line 2408 of file PyBasic.c.

{
       if ((ch >= 'A') && (ch <= 'Z'))
              return TRUE;
              
       return FALSE;
}

Here is the caller graph for this function:

JINT IsValidSpSuite ( CHAR  chSM,
CHAR  chYM,
JINT  nKeyLayMode 
)

Definition at line 2595 of file PyBasic.c.

{
       CHAR    szYjTmp1[10], szYjTmp2[10];
       JINT    nKeyLayYM1, nKeyLayYM2, nKeyLaySM;
       JINT    i, m, nRes;
       JINT    nNullYj[8] = {27, 50, 64, 82, 90, 152, 235, 285};

       assert(((chSM >= 'a') && (chSM <= 'z')) || ((chSM >= 'A') && (chSM <= 'Z')));
       assert(((chYM >= 'a') && (chYM <= 'z')) || ((chYM >= 'A') && (chYM <= 'Z')));

       if ((Lower(chSM) == 'i') || (Lower(chSM) == 'u') || (Lower(chSM) == 'v'))
       {
              nKeyLaySM   = KEYLAYMODE[nKeyLayMode][Lower(chSM) - 'a'] >> 16;
              szYjTmp1[0] = szYjTmp2[0] = YUNMUSTR[nKeyLaySM][0];
              szYjTmp1[1] = szYjTmp2[1] = YUNMUSTR[nKeyLaySM][1];
              szYjTmp1[2] = szYjTmp2[2] = '\0';
              m = 2;    /* length of ShengMu */
       }
       else
       {
              szYjTmp1[0] = szYjTmp2[0] = Lower(chSM);
              szYjTmp1[1] = szYjTmp2[1] = '\0';
              m = 1;    /* length of ShengMu */
       }

       nKeyLayYM1  =  KEYLAYMODE[nKeyLayMode][Lower(chYM) - 'a'] & 0x0000FF;
       nKeyLayYM2  = (KEYLAYMODE[nKeyLayMode][Lower(chYM) - 'a'] & 0x00FF00) >> 8;

       /* ShengMu just before it is [aeo] */
       if ((chSM == 'a') || (chSM == 'e') || (chSM == 'o'))
              szYjTmp1[0]  = szYjTmp2[0] = '\0';

       strcat(szYjTmp1, YUNMUSTR[nKeyLayYM1]);
       nRes = FastMatchYinJieStr(szYjTmp1);

       /* Process for Null Yinjie in "zh" locale. Scott Ma 98-05-13 */
#ifndef _DRAW_IM_WIN_H
       if (strcmp(szLocale, "zh") == 0)
       {
              for (i = 0; i < 8; i++)
              {
                     if (nRes == nNullYj[i])
                     {
                            nRes = -1;
                            break;
                     }
              }
       }
#endif

       if ((nRes >= 0) && (nRes < NUM_YINJIE))
              return TRUE;

       if ((nRes == -1) && (nKeyLayYM2 != 0))
       {
              strcat(szYjTmp2, YUNMUSTR[nKeyLayYM2]);
              nRes = FastMatchYinJieStr(szYjTmp2);

              /* Process for Null Yinjie in "zh" locale. Scott Ma 98-05-13 */
#ifndef _DRAW_IM_WIN_H
              if (strcmp(szLocale, "zh") == 0)
              {
                     for (i = 0; i < 8; i++)
                     {
                            if (nRes == nNullYj[i])
                            {
                                   nRes = -1;
                                   break;
                            }
                     }
              }
#endif

              if ((nRes >= 0) && (nRes < NUM_YINJIE))
                     return TRUE;
       }
       
       return FALSE;
}
CHAR LastChar ( JINT  nYinjieCode)

Definition at line 1848 of file PyBasic.c.

{
       CHAR   res = ' ';           /* SPACE */
       JINT   i = 0;
       
       if ((nYinjieCode >= 0) && (nYinjieCode <= 414))
       {
              while (YINJIESTR_CSZ[nYinjieCode][i] != '\0')
                     i++;
              res = YINJIESTR_CSZ[nYinjieCode][i-1];
       }
       return res;
}

Here is the caller graph for this function:

CHAR Lower ( CHAR  ch)

Definition at line 2400 of file PyBasic.c.

{
       if ((ch >= 'A') && (ch <= 'Z'))
              return (CHAR)(ch + 'a' - 'A');
              
       return (ch);
}

Here is the caller graph for this function:

UCHAR* RecovDyz2244 ( UCHAR szDyz2244)

Definition at line 1972 of file PyBasic.c.

{
       JINT    i, j, nLen, nHlfLen;
       JINT    nDyzCode, nNormCode;
       static  UCHAR*  szNorm = NULL; 
   
       nLen = strlen((CHAR*)szDyz2244);
       nHlfLen = nLen / 2;

       if(szNorm != NULL)
              free(szNorm);

       szNorm = (UCHAR*)malloc(nLen + MALIGN);
       if (szNorm == NULL)
       {
              fprintf(stderr, "Failed to alloc Memory in function RecovDyz2244()\n");
              return (szNorm);
       }
       memset(szNorm, '\0', (nLen + MALIGN));
       
       j = 0;
       for (i = 0; i < nHlfLen; i++)
       {
              nDyzCode = szDyz2244[(2 * i) + 1] + ((JINT)szDyz2244[2 * i] << 8);
              if ((nDyzCode >= 0x2001) && (nDyzCode <= 0x2244))
              {
                     nNormCode         = DYZLIST[nDyzCode - 0x2001];
                     szNorm[2 * i]     = (UCHAR)((nNormCode & 0xFF00) >> 8);
                     szNorm[2 * i + 1] = (UCHAR)(nNormCode & 0x00FF);
              }
              else
              {
                     szNorm[2 * i]      = szDyz2244[2 * i];
                     szNorm[2 * i + 1]  = szDyz2244[2 * i + 1];
              }
       }
       
       return (szNorm);
}
JWORD* RecovDyzNWord2244 ( JWORD pwDyz2244,
JINT  nMaxLen 
)

Definition at line 2032 of file PyBasic.c.

{
       static JWORD*  pwRet = NULL;
       JINT    i;

       free (pwRet);
       pwRet = (JWORD*)malloc((nMaxLen + MALIGN) * sizeof(JWORD));
       if (pwRet == NULL)
       {
              fprintf(stderr, "Failed in malloc() of RecovDyzNWord2244().\n");
              return pwRet;
       }
       memset(pwRet, '\0', sizeof(JWORD) * (nMaxLen + MALIGN));

       for (i = 0; (i < nMaxLen) && (pwDyz2244[i] != 0x0000); i++)
       {
              if ((pwDyz2244[i] >= 0x2001) && (pwDyz2244[i] <= 0x2244))
                     pwRet[i]  = (JWORD)DYZLIST[pwDyz2244[i] - 0x2001];
              else
                     pwRet[i]  = pwDyz2244[i];
       }

       return pwRet;
}
JWORD RecovDyzWord2244 ( JWORD  wDyz2244)

Definition at line 2016 of file PyBasic.c.

{
       JWORD    wRet;
       
       wRet = wDyz2244;
       
       if ((wDyz2244 >= 0x2001) && (wDyz2244 <= 0x2244))
              wRet  = (JWORD)DYZLIST[wDyz2244 - 0x2001];
       
       return wRet;
}
JINT Sp2QpStr ( CHAR pszOrgSp,
CHAR pszUnifSp,
CHAR pszQp,
JINT  nKeyLayMode 
)

Definition at line 2080 of file PyBasic.c.

{
       JINT    nLen, i, j, k, m, nRes;
       CHAR    szYjTmp1[10], szYjTmp2[10];
       JINT    nfStartSM, nfStartYM;
       JINT    nKeyLayYM1, nKeyLayYM2, nKeyLaySM;

#ifdef _DEBUG
       if ((nKeyLayMode < 0) || (nKeyLayMode >= 3))
       {
              fprintf (stderr, "Error nKeyLayMode [%d] in Sp2QpStr().\n", nKeyLayMode);
              return FALSE;
       }
#endif

       UnifOrgSpStr(pszOrgSp, pszUnifSp);

       memset (szYjTmp1, '\0', 10);
       memset (szYjTmp2, '\0', 10);
       nfStartSM = TRUE;
       nfStartYM = FALSE;
       i = j = 0;
       nLen = strlen(pszUnifSp);

       for (i = 0; i < nLen; )
       {
              if (pszUnifSp[i] == '\'')
              {
                     pszQp[j++] = '\'';
                     nfStartSM  = TRUE;
                     nfStartYM  = FALSE;
                     i++;
              }
              else if (nfStartSM == TRUE)
              {
                     /* To "ch" "sh" "zh" */
                     if ((pszUnifSp[i] == 'i') || (pszUnifSp[i] == 'u') || (pszUnifSp[i] == 'v'))
                     {
                            nKeyLaySM   = KEYLAYMODE[nKeyLayMode][pszUnifSp[i] - 'a'] >> 16;
                            pszQp[j++]  = szYjTmp1[0] = szYjTmp2[0] = YUNMUSTR[nKeyLaySM][0];
                            pszQp[j++]  = szYjTmp1[1] = szYjTmp2[1] = YUNMUSTR[nKeyLaySM][1];
                            szYjTmp1[2] = szYjTmp2[2] = '\0';
                            m = 2;    /* length of ShengMu */
                     }
                     else
                     {
                            pszQp[j++]  = szYjTmp1[0] = szYjTmp2[0] = pszUnifSp[i];
                            szYjTmp1[1] = szYjTmp2[1] = '\0';
                            m = 1;    /* length of ShengMu */
                     }
                     i++;
                     nfStartSM  = FALSE;
                     nfStartYM  = TRUE;
              }
              else if (nfStartYM == TRUE)
              {
                     nKeyLayYM1 = KEYLAYMODE[nKeyLayMode][pszUnifSp[i] - 'a'] & 0x0000FF;
                     nKeyLayYM2 = (KEYLAYMODE[nKeyLayMode][pszUnifSp[i] - 'a'] & 0x00FF00) >> 8;

                     /* ShengMu just before it is [aeo] */
                     if ((pszUnifSp[i - 1] == 'a') || (pszUnifSp[i - 1] == 'e') || (pszUnifSp[i - 1] == 'o'))
                            szYjTmp1[0]  = szYjTmp2[0] = '\0';

                     strcat(szYjTmp1, YUNMUSTR[nKeyLayYM1]);
                     nRes = FastMatchYinJieStr(szYjTmp1);
                     if ((nRes >= 0) && (nRes < NUM_YINJIE))
                     {
                            for (k = m; szYjTmp1[k] != '\0'; k++)
                                   pszQp[j++] = szYjTmp1[k];
                            i++;
                     }

                     if ((nRes == -1) && (nKeyLayYM2 != 0))
                     {
                            strcat(szYjTmp2, YUNMUSTR[nKeyLayYM2]);
                            nRes = FastMatchYinJieStr(szYjTmp2);
                            if ((nRes >= 0) && (nRes < NUM_YINJIE))
                            {
                                   for (k = m; szYjTmp2[k] != '\0'; k++)
                                          pszQp[j++] = szYjTmp2[k];
                                   i++;
                            }
                     }

                     nfStartSM  = TRUE;
                     nfStartYM  = FALSE;
                     memset (szYjTmp1, '\0', 10);
                     memset (szYjTmp2, '\0', 10);
              }
       }

       pszQp[j] = '\0';
       return TRUE;
}

Here is the call graph for this function:

JINT Sp2QpStr_Better ( CHAR pszOrgSp,
CHAR pszQp,
JINT  nKeyLayMode,
JINT  nSpCaretPos,
JINT pnQpCaretPos 
)

Definition at line 2227 of file PyBasic.c.

{
       JINT    nLen, i, j, k, m, nRes;
       CHAR    szYjTmp1[10], szYjTmp2[10];
       JINT    nfStartSM, nfStartYM;
       JINT    nKeyLayYM1, nKeyLayYM2, nKeyLaySM;
       
#ifdef _DEBUG
       if ((nKeyLayMode < 0) || (nKeyLayMode >= 3))
       {
              fprintf (stderr, "Error nKeyLayMode [%d] in Sp2QpStr().\n", nKeyLayMode);
              return FALSE;
       }
#endif

       memset (szYjTmp1, '\0', 10);
       memset (szYjTmp2, '\0', 10);
       nfStartSM = TRUE;
       nfStartYM = FALSE;
       i = j = 0;
       nLen = strlen(pszOrgSp);

       for (i = 0; i < nLen; )
       {
              /* Cacluates Caret Position */
              if ( nSpCaretPos == i)
                     *pnQpCaretPos = strlen (pszQp);
              
              if (pszOrgSp[i] == '\'')
              {
                     if (!((j > 0) && (pszQp[j - 1] == '\'')))
                            pszQp[j++] = '\'';
                     nfStartSM  = TRUE;
                     nfStartYM  = FALSE;
                     i++;
                     
                     continue;
              }
              
              if (pszOrgSp[i] == '$')
              {
                     if ((j > 0) && (pszQp[j - 1] != '\'') && (pszQp[j - 1] != '$'))
                            pszQp[j++] = '$';
                     nfStartSM  = TRUE;
                     nfStartYM  = FALSE;
                     i++;
                     
                     continue;
              }
              
              if (pszOrgSp[i] == '#')
              {
                     if ((j > 0) && (pszQp[j - 1] != '\'') && (pszQp[j - 1] != '$') && (pszQp[j - 1] != '#'))
                            pszQp[j++] = '#';
                     nfStartSM  = TRUE;
                     nfStartYM  = FALSE;
                     i++;
                     
                     continue;
              }

              /* For a UpperCase [A], it was treated as ShengMu and was replaced with [#a#] */
              if (nfStartSM == TRUE)
              {
                     if (IsUpper(pszOrgSp[i]))
                     {
                            if ((j > 0) && (pszQp[j - 1] != '\'') && (pszQp[j - 1] != '$') && (pszQp[j - 1] != '#'))
                                   pszQp[j++] = '#';
                     }
                     
                     /* To "ch" "sh" "zh" */
                     if ((Lower(pszOrgSp[i]) == 'i') || (Lower(pszOrgSp[i]) == 'u') || (Lower(pszOrgSp[i]) == 'v'))
                     {
                            nKeyLaySM   = KEYLAYMODE[nKeyLayMode][Lower(pszOrgSp[i]) - 'a'] >> 16;
                            pszQp[j++]  = szYjTmp1[0] = szYjTmp2[0] = YUNMUSTR[nKeyLaySM][0];
                            pszQp[j++]  = szYjTmp1[1] = szYjTmp2[1] = YUNMUSTR[nKeyLaySM][1];
                            szYjTmp1[2] = szYjTmp2[2] = '\0';
                            m = 2;    /* length of ShengMu */
                     }
                     else
                     {
                            pszQp[j++]  = szYjTmp1[0] = szYjTmp2[0] = Lower(pszOrgSp[i]);
                            szYjTmp1[1] = szYjTmp2[1] = '\0';
                            m = 1;    /* length of ShengMu */
                     }
                     
                     if (IsUpper(pszOrgSp[i]))
                     {
                            pszQp[j++] = '#';          /* Add a [#] ??? MXL ????? Necessary!! Indeed!!! */
                            nfStartSM  = TRUE;
                            nfStartYM  = FALSE;
                     }
                     else
                     {
                            nfStartSM  = FALSE;
                            nfStartYM  = TRUE;
                     }
                     i++;

              }
              else if (nfStartYM == TRUE)
              {
                     /* If it is in Upper Case, treat it as ShengMu */
                     if (IsUpper(pszOrgSp[i]))
                     {
                            nfStartSM  = TRUE;
                            nfStartYM  = FALSE;
                            continue;
                     }
                     
                     nKeyLayYM1 = KEYLAYMODE[nKeyLayMode][pszOrgSp[i] - 'a'] & 0x0000FF;
                     nKeyLayYM2 = (KEYLAYMODE[nKeyLayMode][pszOrgSp[i] - 'a'] & 0x00FF00) >> 8;

                     /* ShengMu just before it is [aeo] */
                     if ((pszOrgSp[i - 1] == 'a') || (pszOrgSp[i - 1] == 'e') || (pszOrgSp[i - 1] == 'o'))
                            szYjTmp1[0]  = szYjTmp2[0] = '\0';
                            
                     /* To Process 'aa' 'ee' 'oo' ......????? */

                     strcat(szYjTmp1, YUNMUSTR[nKeyLayYM1]);
                     nRes = FastMatchYinJieStr(szYjTmp1);
                     if ((nRes >= 0) && (nRes < NUM_YINJIE))
                     {
                            for (k = m; szYjTmp1[k] != '\0'; k++)
                                   pszQp[j++] = szYjTmp1[k];
                            i++;
                     }

                     if ((nRes == -1) && (nKeyLayYM2 != 0))
                     {
                            strcat(szYjTmp2, YUNMUSTR[nKeyLayYM2]);
                            nRes = FastMatchYinJieStr(szYjTmp2);
                            if ((nRes >= 0) && (nRes < NUM_YINJIE))
                            {
                                   for (k = m; szYjTmp2[k] != '\0'; k++)
                                          pszQp[j++] = szYjTmp2[k];
                                   i++;
                            }
                     }
                     
                     if ((j > 0) && (pszQp[j - 1] != '\'') && (pszQp[j - 1] != '#'))
                            pszQp[j++] = '#';

                     nfStartSM  = TRUE;
                     nfStartYM  = FALSE;
                     memset (szYjTmp1, '\0', 10);
                     memset (szYjTmp2, '\0', 10);
              }
       }
       
       if ((j > 0) && (pszQp[j - 1] == 0x23))           /* [#] */
              pszQp[j - 1] = '\0';
       
       if (nLen == nSpCaretPos)
              *pnQpCaretPos = strlen (pszQp);

       pszQp[j] = '\0';
       
       return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JINT TypeOfSpChar ( CHAR pszOrgSp,
JINT  nPos,
JINT  nKeyLayMode 
)

Definition at line 2435 of file PyBasic.c.

{
       JINT    nLen, i, j, k, m, nRes;
       CHAR    szYjTmp1[10], szYjTmp2[10];
       JINT    nfStartSM, nfStartYM;
       JINT    nKeyLayYM1, nKeyLayYM2, nKeyLaySM;
       
       memset (szYjTmp1, '\0', 10);
       memset (szYjTmp2, '\0', 10);
       nfStartSM = TRUE;
       nfStartYM = FALSE;
       i = j = 0;
       
       nLen = strlen(pszOrgSp);

       if ((nPos < 0) || (nPos >= nLen))
              return SPYJ_INVALID;
              
       /* Valid nPos is  [0 ~ (nLen - 1)] */
       for (i = 0; i <= nPos; )
       {
              if (pszOrgSp[i] == '\'')
              {
                     nfStartSM  = TRUE;
                     nfStartYM  = FALSE;

                     if (nPos == i)
                            return SPYJ_QUOTE;
                     else
                            i++;
                     
                     continue;
              }
              
              if (pszOrgSp[i] == '#')
              {
                     nfStartSM  = TRUE;
                     nfStartYM  = FALSE;

                     if (nPos == i)
                            return SPYJ_NUMSIGN;
                     else
                            i++;
                     
                     continue;
              }
              
              if (pszOrgSp[i] == '$')
              {
                     nfStartSM  = TRUE;
                     nfStartYM  = FALSE;

                     if (nPos == i)
                            return SPYJ_DOLLAR;
                     else
                            i++;
                     
                     continue;
              }

              /* For a UpperCase [A], it was treated as ShengMu and was replaced with ['a'] */
              if (nfStartSM == TRUE)
              {
                     /* To "ch" "sh" "zh" */
                     if ((Lower(pszOrgSp[i]) == 'i') || (Lower(pszOrgSp[i]) == 'u') || (Lower(pszOrgSp[i]) == 'v'))
                     {
                            nKeyLaySM   = KEYLAYMODE[nKeyLayMode][Lower(pszOrgSp[i]) - 'a'] >> 16;
                            szYjTmp1[0] = szYjTmp2[0] = YUNMUSTR[nKeyLaySM][0];
                            szYjTmp1[1] = szYjTmp2[1] = YUNMUSTR[nKeyLaySM][1];
                            szYjTmp1[2] = szYjTmp2[2] = '\0';
                            m = 2;    /* length of ShengMu */
                     }
                     else
                     {
                            szYjTmp1[0] = szYjTmp2[0] = Lower(pszOrgSp[i]);
                            szYjTmp1[1] = szYjTmp2[1] = '\0';
                            m = 1;    /* length of ShengMu */
                     }
                     
                     if (IsUpper(pszOrgSp[i]))
                     {
                            nfStartSM  = TRUE;
                            nfStartYM  = FALSE;
                     }
                     else
                     {
                            nfStartSM  = FALSE;
                            nfStartYM  = TRUE;
                     }

                     if (nPos == i)
                            return SPYJ_SHENGMU;
                     
                     i++;

              }
              else if (nfStartYM == TRUE)
              {
                     /* If it is in Upper Case, treat it as ShengMu */
                     if (IsUpper(pszOrgSp[i]))
                     {
                            nfStartSM  = TRUE;
                            nfStartYM  = FALSE;
                            continue;
                     }
                     
                     nKeyLayYM1 = KEYLAYMODE[nKeyLayMode][pszOrgSp[i] - 'a'] & 0x0000FF;
                     nKeyLayYM2 = (KEYLAYMODE[nKeyLayMode][pszOrgSp[i] - 'a'] & 0x00FF00) >> 8;

                     /* ShengMu just before it is [aeo] */
                     if ((pszOrgSp[i - 1] == 'a') || (pszOrgSp[i - 1] == 'e') || (pszOrgSp[i - 1] == 'o'))
                            szYjTmp1[0]  = szYjTmp2[0] = '\0';

                     strcat(szYjTmp1, YUNMUSTR[nKeyLayYM1]);
                     nRes = FastMatchYinJieStr(szYjTmp1);
                     if ((nRes >= 0) && (nRes < NUM_YINJIE))
                     {
                            if (nPos == i)
                                   return SPYJ_YUNMU;
                            i++;
                     }

                     if ((nRes == -1) && (nKeyLayYM2 != 0))
                     {
                            strcat(szYjTmp2, YUNMUSTR[nKeyLayYM2]);
                            nRes = FastMatchYinJieStr(szYjTmp2);
                            if ((nRes >= 0) && (nRes < NUM_YINJIE))
                            {
                                   if (nPos == i)
                                          return SPYJ_YUNMU;
                                   i++;
                            }
                     }

                     nfStartSM  = TRUE;
                     nfStartYM  = FALSE;
                     memset (szYjTmp1, '\0', 10);
                     memset (szYjTmp2, '\0', 10);
              }
       }
       
       return SPYJ_INVALID;
}
VOID UnifOrgSpStr ( CHAR pszOrgSp,
CHAR pszUnifSp 
)

Definition at line 2179 of file PyBasic.c.

{
       JINT    nLen, i, j;

       nLen = strlen(pszOrgSp);

       i = j = 0;
       for (i = 0; i < nLen; i++)
       {
              if ((pszOrgSp[i] >= 'A') && (pszOrgSp[i] <= 'Z'))
              {
                     pszUnifSp[j++] = pszOrgSp[i] + 'a' - 'A';
                     pszUnifSp[j++] = '\'';
              }
              else if (pszOrgSp[i] == '\'')
              {
                     if ((j > 0) && (pszUnifSp[j - 1] != '\''))
                            pszUnifSp[j++] = '\'';
              }
              else if ((pszOrgSp[i] >= 'a') && (pszOrgSp[i] <= 'z'))
                     pszUnifSp[j++] = pszOrgSp[i];
              else
              {
#ifdef _DEBUG
                     fprintf (stderr, "Error in UnifOrgSpStr(): Unexpected char: [%d]%c\n", i, pszOrgSp[i]);
#endif
              }
       }

       pszUnifSp[j] = '\0';
}

Here is the caller graph for this function:

CHAR Upper ( CHAR  ch)

Definition at line 2392 of file PyBasic.c.

{
       if ((ch >= 'a') && (ch <= 'z'))
              return (CHAR)(ch + 'A' - 'a');
              
       return (ch);
}
JINT ValidAddChar ( CHAR  ch,
JINT  nYinjieCode 
)

Definition at line 1909 of file PyBasic.c.

{
       JINT    i, nTmpRes;
       CHAR    szStr[7];
       
       for (i = 0; i < 7; i++)
              szStr[i] = '\0';

       szStr[0] = ch;
       if ((nYinjieCode >= 0) && (nYinjieCode <= 414))
       {
              i = 0; 
              while (YINJIESTR_CSZ[nYinjieCode][i])
              {
                     szStr[i + 1] = YINJIESTR_CSZ[nYinjieCode][i];
                     i++;
              }
                     
              nTmpRes = FastMatchYinJieStr(szStr);
              if(nTmpRes != -1)
                     return nTmpRes;
       }
       
       return 0xFFFF;
}

Here is the caller graph for this function:

JINT ValidButFirstChar ( JINT  nYinjieCode)

Definition at line 1940 of file PyBasic.c.

{
       JINT    i, nTmpRes;
       CHAR    szStr[7];
       
       for (i = 0; i < 7; i++)
              szStr[i] = '\0';
       
       if ((nYinjieCode >= 0) && (nYinjieCode <= 414))
       {
              i = 0; 
              while (YINJIESTR_CSZ[nYinjieCode][i+1])
              {
                     szStr[i] = YINJIESTR_CSZ[nYinjieCode][i+1];
                     i++;
              }
                     
              nTmpRes = FastMatchYinJieStr(szStr);
              if(nTmpRes != -1)
                     return nTmpRes;
       }
       
       return 0xFFFF;
}

Here is the caller graph for this function:

JINT ValidButLastChar ( JINT  nYinjieCode)

Definition at line 1880 of file PyBasic.c.

{
       JINT    i, nTmpRes;
       CHAR    szStr[7];
       
       for (i = 0; i < 7; i++)
              szStr[i] = '\0';
       
       if ((nYinjieCode >= 0) && (nYinjieCode <= 414))
       {
              i = 0; 
              while (YINJIESTR_CSZ[nYinjieCode][i+1])
              {
                     szStr[i] = YINJIESTR_CSZ[nYinjieCode][i];
                     i++;
              }
                     
              nTmpRes = FastMatchYinJieStr(szStr);
              if(nTmpRes != -1)
                     return nTmpRes;
       }
       return 0xFFFF;
}

Here is the caller graph for this function:


Variable Documentation

Initial value:
 {
    0x285C2A8E, 0xF7784DE2, 0x1378BC9E, 0x40C0984C, 0x28FF7FBD, 0xC14F87C0, 0x19FA130E, 0x4D2FB25C, 0x65FF161E,
    0x138542F2, 0xFC6E3805, 0x8FC7A385, 0x935208B2, 0x6C2B84D9, 0xB359B156, 0x28740197, 0x8A25F421, 0xF90B183E,
    0x1F526959, 0x3A6D3494, 0x4A278909, 0xA4BA954D, 0x0370AE3C, 0x5FAFC2EB, 0xDC1AFF31, 0x9D4BC843, 0x8A12EC02,
    0x48C251C0, 0xB0025CF8, 0x7C4198CE, 0xAD039341, 0x0E67AF1F, 0x902F7392, 0x7ED47D80, 0x403185E4, 0x49A51294,
    0xAFC0EC10, 0x4485B920, 0x90CF0A91, 0xD624217D, 0x1666C41A, 0x1117947D, 0xA8BD0131, 0xAF912618, 0x21C8E86E,
    0x409AB175, 0xD692F957, 0x78552D16, 0x0A9552E5, 0x6AB85ACE, 0x9726C52A, 0xA552C268, 0x55990D06, 0x8302DCD0,
    0x673198C0, 0xD06D59A4, 0xC0603497, 0xED56CB69, 0xB2D96D3B, 0x1A8D46EB, 0x808B2A5B, 0xB62DC507, 0x7BC41209,
    0xB5BEC241, 0x3A9BC028, 0xF97E8241, 0x284AEA11, 0x0884B141, 0x6D860432, 0x510F3142, 0xA3A0EEE4, 0x7DA0DD04,
    0x88C8A5D2, 0xC134B453, 0x21B85905, 0xA3B9A497, 0x28A4CA4D, 0xF2F979F8, 0x8E673DBC, 0x4783D36B, 0x34A07330,
    0x14DB8855, 0x2CE93E80, 0xD0B85DAE, 0xD9838342, 0xBF5F421F, 0x0E32D3B4, 0x08E96902, 0x2210B6F3, 0xA1E61536,
    0x18D8ADF7, 0x1B1666B0, 0x63B60BE7, 0x167B9DE6, 0xDD6EBD08, 0xB158C0ED, 0xE84C5EB5, 0xCBEF57F6, 0xF4C66591,
    0xC1CDA6C2, 0xF17DDB1F, 0x6FCCE1C6, 0xD8AC7E40, 0x3D7BC108, 0x716AD803, 0x84268597, 0xDC058462, 0xF4060AD5,
    0x92A2574B, 0xE44DB1EE, 0xFDAC5AAC, 0xF7117534, 0x140DBB97, 0x6140DCBD, 0x2ABB48C1, 0xC02E4F93, 0x62C01576,
    0x895F6EAF, 0xB725F17C, 0x6BA35468, 0x8BFA0BDC, 0x0C6A0F44, 0x71E33C5D, 0x01215B96, 0xB4EE0771, 0x9E645B69,
    0x1335AEE3, 0xDA6C12AA, 0x56CA50E0, 0xD9556C14, 0xE6F8CD4F, 0x1FA9FB3B, 0x2AE309C9, 0x5007628A, 0x0BE4ED48,
    0x7C33DA32, 0x1BF160E8, 0x825103F0, 0x88EBC54D, 0x6AA440E4, 0x84C12C42, 0x301B0296, 0xCB0276CB, 0x8576B82A,
    0xBC8F5BB0, 0x097B8A8B, 0x9BA059D7, 0xCB6A63BE, 0x93531691, 0xEDCB5A15, 0x8C9CBEBB, 0x1F07225A, 0xF5AA0397,
    0xAEBDE716, 0xB4541A85, 0x623B25EC, 0x375C55E6, 0x6900CB5D, 0x60B8A9B0, 0x4C8D5DC4, 0x2C2BF716, 0x5673267C,
    0x97C09A10, 0xD0000000
}

Definition at line 1505 of file PyBasic.c.

Definition at line 306 of file PyBasic.c.

Definition at line 385 of file PyBasic.c.

Definition at line 570 of file PyBasic.c.

Definition at line 792 of file PyBasic.c.

UCHAR HIFREQHANZI[26][14]
Initial value:
 {
    "按啊安爱案阿澳",
    "不并比把部标报",
    "从此采才材次存",
    "产出成厂场车处",
    "的地得大吨对多",
    "而二尔儿恶恩耳",
    "分发非飞放反费",
    "个工过各改该国",
    "和还会合后或号",
    "及就将讲据加件",
    "可开空口科克看",
    "了来类理量力利",
    "每没名面民们门",
    "能年你内农那女",
    "欧偶殴藕喔呕沤",
    "品平排配破盘片",
    "其起且区全前求",
    "人如让入然日认",
    "所三四色斯随司",
    "是使上说十生时",
    "他她它天同特台",
    "我无外为位文问",
    "向学新行系性信",
    "一要有以于与由",
    "在总子自再最作",
    "这之者着中种主"
}

Definition at line 1530 of file PyBasic.c.

Initial value:
 
{ 
  
     0,  1,  2,  4,  5,  6,  7,  8,  3,  9, 10, 11, 12,
     
  
    13, 14, 15, 16, 17, 18, 20, 19, 25, 21, 22, 23, 24
}

Definition at line 93 of file PyBasic.c.

Initial value:
 {
      0,  13,  21,  37,  50,  56,  67,  81,  87,  94,  99, 112, 121, 
         129, 142, 148, 160, 170, 174, 186, 198, 216, 224, 242, 252, 
         258, 265, 277, 287, 291, 296, 302, 313, 321, 324, 329, 333, 
         345, 352, 358, 371, 380, 388, 393, 400, 411, 417, 424, 435, 
         452, 457, 460, 467, 474, 476, 479, 489, 497, 501, 507, 508, 
         517, 524, 530, 536, 541, 551, 556, 558, 563, 569, 575, 580  
}

Definition at line 466 of file PyBasic.c.

Initial value:
 
{

      0,    5,   21,    38,   57,
      

     80,   84,   94,   113,  132,


    146,  165,  191,   211,  237,


    239,  256,       270,   285,  301,


    320,  340,       349,   363,  378,


    395,  415
}

Definition at line 68 of file PyBasic.c.

JINT KEYLAYMODE[3][27]

Definition at line 163 of file PyBasic.c.

UCHAR NONLINKHZ[2 *NUM_NONLINKHZ+2] = "是的了不也而你我他与它她其就和或"

Definition at line 1560 of file PyBasic.c.

UCHAR PRELINKHZ[2 *NUM_PRELINKHZ+2] = "们性员子上下中内外化者家儿年月日时分秒街路村"

Definition at line 1565 of file PyBasic.c.

Initial value:
{
   
    "a",  "b",  "c",  "ch", "d",  
    "e",  "f",  "g",  "h",  "j",  
    "k",  "l",  "m",  "n",  "o",  
    "p",  "q",  "r",  "s",  "sh", 
    "t",  "w",  "x",  "y",  "z",  
    "zh"
}

Definition at line 51 of file PyBasic.c.

UCHAR SUFLINKHZ[2 *NUM_SUFLINKHZ+2] = "不在这从到那哪第各每某本总当由如以为被使更且指于但将可应会该此全很都近约"

Definition at line 1570 of file PyBasic.c.

Definition at line 73 of file CikuOper.c.

Definition at line 207 of file PyBasic.c.

Definition at line 479 of file PyBasic.c.

CHAR* YUNMUSTR[37]
Initial value:
{
  
    "",
  
  
    "a",    "ai",   "an",   "ang",  "ao",   "e",    "ei",   "en",   "eng",  "er", 

  
    "i",    "ia",   "ian",  "iang", "iao",  "ie",   "in",   "ing",  "iong", "iu",

  
    "o",    "ong",  "ou",   "u",    "v",    "ua",   "uai",  "uan",  "uang", "ue",

  
    "ui",   "un",   "uo",

  
  
    "ch",   "sh",   "zh"
}

Definition at line 141 of file PyBasic.c.