• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            road420

            導航

            <2008年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            統計

            常用鏈接

            留言簿(2)

            隨筆檔案

            文章檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            字符類型數據轉換

            1/**///////////////////////////////////////////////////////////////////////////
              2// Module: stringutility.h
              3// Conversion among wchar_t, char and TCHAR
              4//
              5/**///////////////////////////////////////////////////////////////////////////
              6#ifndef _STRINGUTILITY_H_
              7#define _STRINGUTILITY_H_
              8
              9/**///////////////////////////////////////////////////////////////////////////
             10// get PSTR by PWSTR
             11// This function malloc some memory and you must free it
             12inline char* newPSTRFromPWSTRT(PWSTR source)
             13{
             14    char *pCh = NULL;
             15    int nLength = 0;
             16    if(!source)
             17    {
             18        pCh = new char[1];
             19    }

             20    else
             21    {
             22        nLength= wcslen(source);
             23        pCh = new char[2 * nLength + 1];
             24        WideCharToMultiByte(CP_ACP,
             25            0,
             26            source,
             27            -1,
             28            pCh,
             29            nLength * 2,
             30            NULL,
             31            NULL);
             32    }

             33    pCh[2 * nLength] = '\0';
             34    return pCh;
             35}

             36
             37/**///////////////////////////////////////////////////////////////////////////
             38// get PWSTR by PSTR
             39// This function malloc some memory and you must free it
             40inline wchar_t* newPWSTRFromPSTR(PSTR source)
             41{
             42    wchar_t *pCh = NULL;
             43    int nLength = 0;
             44    if(!source)
             45    {
             46        pCh = new wchar_t[1];
             47    }

             48    else
             49    {
             50        nLength = strlen(source);
             51        pCh = new wchar_t[nLength + 1];
             52        MultiByteToWideChar(CP_ACP,
             53            0,
             54            source,
             55            -1,
             56            pCh,
             57            nLength);
             58    }

             59    pCh[nLength] = '\0';
             60    return pCh;
             61}

             62
             63/**///////////////////////////////////////////////////////////////////////////
             64// get PSTR by PTSTR
             65// This function malloc some memory and you must free it
             66
             67inline char* newPSTRFromPTSTR(PTSTR    source)
             68{
             69#ifdef UNICODE
             70    return newPSTRFromPWSTRT(source);
             71#else
             72    char* pCh;
             73    int iLength = 0;
             74    if(!source)
             75    {
             76        pCh = new char[1];
             77    }

             78    else
             79    {
             80        iLength = strlen(source);
             81        pCh = new char[iLength +1];
             82        strcpy(pCh, source);
             83    }

             84    pCh[iLength] = '\0';
             85    return pCh;
             86#endif
             87}

             88
             89/**///////////////////////////////////////////////////////////////////////////
             90// get PWSTR by PTSTR
             91// This function malloc some memory and you must free it
             92
             93inline wchar_t* newPWSTRFromPTSTR(PTSTR source)
             94{
             95#ifdef UNICODE
             96    wchar_t *pCh = NULL;
             97    int nLength = 0;
             98    if(!source)
             99    {
            100        pCh = new wchar_t[1];
            101    }

            102    else
            103    {
            104        nLength = wcslen(source);
            105        pCh = new wchar_t[nLength + 1];
            106        wcscpy(pCh, source);
            107    }

            108    pCh[nLength] = L'\0';
            109    return pCh;
            110#else
            111    return newPWSTRFromPTSTR(source);
            112#endif
            113}

            114
            115
            116/**///////////////////////////////////////////////////////////////////////////
            117// get PTSTR by PSTR
            118// This function malloc some memory and you must free it
            119inline TCHAR* newPTSTRFromPSTR(PSTR source)
            120{
            121#ifdef UNICODE
            122    return newPWSTRFromPSTR(source);
            123#else
            124    return newPSTRFromPTSTR(source);
            125#endif
            126}

            127
            128/**///////////////////////////////////////////////////////////////////////////
            129// get PTSTR by PWSTR
            130// This function malloc some memory and you must free it
            131inline TCHAR* newPTSTRFromPWSTR(PWSTR source)
            132{
            133#ifdef UNICODE
            134    return newPWSTRFromPTSTR(source);
            135#else
            136    return newPSTRFromPWSTRT(source);
            137#endif
            138}

            139#endif // end of #ifndef _STRINGUTILITY_H_

            posted on 2008-07-15 08:49 深邃者 閱讀(161) 評論(0)  編輯 收藏 引用

            久久伊人五月天论坛| 久久r热这里有精品视频| 久久久久亚洲AV综合波多野结衣| 日本久久久精品中文字幕| 亚洲欧洲久久av| 91性高湖久久久久| 亚洲成色WWW久久网站| 超级碰久久免费公开视频| 日韩人妻无码一区二区三区久久| 精品久久久久一区二区三区| 国产精品久久自在自线观看| 亚洲国产精品无码成人片久久| 日韩精品久久久久久| 久久久久亚洲av综合波多野结衣| 久久久久久噜噜精品免费直播 | 曰曰摸天天摸人人看久久久| 久久婷婷午色综合夜啪| 人妻精品久久久久中文字幕 | 久久影视综合亚洲| 色综合久久88色综合天天| 中文字幕无码精品亚洲资源网久久 | 国产精品美女久久久网AV| 久久久久久国产精品无码超碰| 亚洲va久久久噜噜噜久久男同| 欧美亚洲另类久久综合婷婷 | 青青草国产精品久久| 久久精品国产亚洲网站| 久久久久亚洲AV成人片| 精品乱码久久久久久久| 国产成人久久精品麻豆一区| 99久久国语露脸精品国产| 久久精品国产亚洲AV高清热| 久久国产色AV免费观看| 久久久噜噜噜www成人网| 久久久久女人精品毛片| 久久99国产综合精品女同| 91精品国产高清91久久久久久| 久久精品中文字幕久久| 大美女久久久久久j久久| 91精品国产综合久久香蕉| 国产亚洲成人久久|