求 vc unicode 编码/GB18030编码 汉字拼音,最好是vc unicode 编码汉字拼音先谢了

解决方案 »

  1.   

    char *
    unicode2s( unsigned char *buf, unsigned short length, char *tmpbuf )
    {
    int i;
    char *p;
    char s[ 10 ] = "";
    wchar_t wstr[ 1 ];
    CString mstr;
    int l, curlen; *tmpbuf = 0;
    curlen = 0;
    mstr = _T( "" ); for( i = 0; i < ( int )length; i += 2 )
    {
    p = ( char * )wstr;
    *p = *( buf ); //high
    *( p + 1 ) = *( buf + 1 ); //low
    mstr = wstr;
    memset( s, 0, sizeof( s ) );
    strcat( s, ( const char * )mstr );
    if( *( buf + 1 ) ) //if low is not 0
    {
    s[ 2 ] = 0;
    l = 2;
    }
    else
    {
    s[ 1 ] = 0;
    l = 1;
    }

    strcat( tmpbuf + curlen, ( const char * )s );
    curlen += l; buf += 2;
    } return tmpbuf;
    }
      

  2.   

    找一份什么FreePY的源代码,其中就有一个码表。如果你想要完整的,那比较难,另外需要注意的是汉语拼音只能是GBK字符集的了。其它文字没有汉语拼音。
      

  3.   

    有一种方法是利用windows api中的ime函数集利用系统中的拼音输入法查出汉字的拼音编码
      

  4.   

    包含Imm32.lib"CString CA01Dlg::GetChineseSpell(CString Chinese,CString IMEName=_T("微软拼音输入法"))
    {
        if( Chinese.IsEmpty() )    return _T("");    HKL KL=NULL;
        int nBuff=GetKeyboardLayoutList(0,NULL);
        HKL* pKLList=new HKL[nBuff];
        GetKeyboardLayoutList(nBuff,pKLList);
        TCHAR* pIMEName;
        int IMENameLen;
        for(int i=0;i<nBuff;i++)
        {
            if(ImmIsIME(pKLList[i]))
            {
                if(IMENameLen=ImmGetDescription(pKLList[i],NULL,0))
                {
                    pIMEName=new TCHAR[IMENameLen+1];
                    if(ImmGetDescription(pKLList[i],pIMEName,IMENameLen))
                    {
                        if(IMEName==pIMEName)
                        {
                            KL=pKLList[i];
                            break;
                        }
                    }
                    delete[] pIMEName;
                }
            }
        }
        delete[] pKLList;
        if(KL==NULL)
            return _T("<NO THE IME NAME>");    static CString retstr;
        CANDIDATELIST* pCDL;
    //    if(BOOL IsDBCS=IsDBCSLeadByte(Chinese.GetAt(0)))
    //    {
            if(LRESULT k=ImmEscape(KL,0,IME_ESC_MAX_KEY,NULL))
            {
                if(UINT len=ImmGetConversionList(KL,NULL,Chinese,NULL,0,GCL_REVERSECONVERSION))
                {
                    pCDL=(CANDIDATELIST*)new BYTE[len];
                    if(UINT x=ImmGetConversionList(KL,NULL,Chinese,pCDL,len,GCL_REVERSECONVERSION))
                        retstr=(char*)pCDL->dwOffset+4;
                    else
                        retstr=_T("<x==0>");
                    delete[] pCDL;
                }
                else retstr=_T("<len==0>");
            }
            else return _T("<k==0>");
    //    }
    //    else return _T("<IsDBCS==FALSE>");
        return retstr;
    }
    为什么我找不到 Imm32.lib 文件
      

  5.   

    Unicode 编码 是不是常用的语言用两字节,不常用的用四字节,不知我说的对不对
      

  6.   

    参阅:http://www.unicode.org/
      

  7.   

    你的代码可以编译阿,但是现实 <No the IME name> 不知道什么原因 ,你的代码那来的?
      

  8.   

    同意
    如果库没加进去,在源码中加
    #include "imm.h"#pragma comment(lib,"imm32.lib")
      

  9.   

    同意
    如果库没加进去,在源码中加
    #include "imm.h"#pragma comment(lib,"imm32.lib")