国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

對于開發SMS初學者的,經常用到的幾個函數。

2019-11-18 20:09:40
字體:
來源:轉載
供稿:網友

/*****************************************************************************
* Class      : Global Function
* Function   : to_MultiByte
* Description: 把Unicode轉換成多字節
* Parameters : char*    strSM -- 要轉換的Unicode緩沖
*              int    nLength -- Unicode緩沖的長度
* Return     : 轉換后的多字節字串
* Input      :
* Output     :
* History    : Created by Rongdian  Monday, APRil 29, 2002   11:03:15
* Process    :
******************************************************************************/
CString to_MultiByte(char* strSM, int nLength){
    UINT nLen = 0;
    PBYTE lpszM;
    PBYTE lpszW = new BYTE[nLength];
    memcpy(lpszW, strSM, nLength);

    for(int i = 0; i < nLength/2; i++)
        *((unsigned short*)lpszW + i) = ntohs(*((unsigned short*)lpszW + i));

    nLen = WideCharToMultiByte(936, WC_COMPOSITECHECK,
            (const unsigned short*)lpszW, nLength/2, NULL, 0, NULL, NULL);

    lpszM = new BYTE[nLen+1];

    nLen = WideCharToMultiByte(936, WC_COMPOSITECHECK,
            (const unsigned short*)lpszW, nLength/2, (char*)lpszM, nLen, NULL, NULL);

    lpszM[nLen] = 0;
    CString CSSM((LPCTSTR)lpszM, nLen);
    delete lpszM;
    delete lpszW;
    return csSM;
}
/*****************************************************************************
* Class      : Global Function
* Function   : to_UCS2
* Description: 把多字節轉換成Unicode
* Parameters : char*    strSM -- -- 要轉換的多字節緩沖
*              int    nLength -- 多字節緩沖的長度
* Return     : 轉換后的Unicode字串
******************************************************************************/
CString to_UCS2(char* strSM, int nLength){
        CString csSM((LPCTSTR)strSM, nLength);
        
        PBYTE    lpszW = NULL;
        UINT    nLen = 0;

        nLen = MultiByteToWideChar(936, MB_PRECOMPOSED,
            (LPCTSTR)csSM, csSM.GetLength(), NULL, 0);

        lpszW = new BYTE[nLen * 2];

        nLen = MultiByteToWideChar(936, MB_PRECOMPOSED,
                (LPCTSTR)csSM, csSM.GetLength(), (LPWSTR)lpszW, nLen);

        for(UINT i = 0; i < nLen; i ++)
            *((unsigned short*)lpszW + i) = htons(*((unsigned short*)lpszW + i));

        CString csRet((LPCTSTR)lpszW, nLen * 2);
        delete lpszW;
        return csRet;
}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 图们市| 阿合奇县| 保定市| 谢通门县| 民勤县| 墨玉县| 昭平县| 正阳县| 多伦县| 庆安县| 高安市| 尉氏县| 宁远县| 云林县| 内丘县| 九龙县| 和静县| 松原市| 阳城县| 安泽县| 赣榆县| 县级市| 济阳县| 寿阳县| 邵阳县| 舟曲县| 运城市| 南平市| 金昌市| 永城市| 应城市| 湘潭市| 常山县| 涞水县| 合山市| 酉阳| 安丘市| 灵武市| 昌黎县| 石首市| 东海县|