• <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

            導(dǎo)航

            <2006年10月>
            24252627282930
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            統(tǒng)計(jì)

            常用鏈接

            留言簿(2)

            隨筆檔案

            文章檔案

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            字符類型數(shù)據(jù)轉(zhuǎn)換

            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 深邃者 閱讀(160) 評(píng)論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            亚洲午夜久久久久久噜噜噜| 久久人与动人物a级毛片| 久久精品无码专区免费东京热| 国产精品久久免费| 欧美午夜精品久久久久久浪潮| 无码日韩人妻精品久久蜜桃| 久久精品国产一区二区三区| 国产精品久久久久久影院| 91精品观看91久久久久久| 人妻精品久久无码专区精东影业| 亚洲精品NV久久久久久久久久| 国产精品美女久久久免费| 久久香蕉综合色一综合色88| 99久久无码一区人妻a黑| 日本欧美久久久久免费播放网| 秋霞久久国产精品电影院| 伊人久久大香线蕉亚洲| 久久精品国产一区二区电影| 99久久99这里只有免费费精品| 亚洲国产成人久久精品99 | 久久婷婷国产麻豆91天堂| 青青青青久久精品国产h久久精品五福影院1421 | 亚洲国产日韩欧美久久| 国产99久久久久久免费看| 久久久久久国产精品无码超碰| 亚洲国产视频久久| 武侠古典久久婷婷狼人伊人| 久久亚洲国产精品一区二区| 久久精品毛片免费观看| 国内精品久久久久影院老司| 久久丫精品国产亚洲av不卡 | 精品久久8x国产免费观看| 欧美亚洲国产精品久久| 色综合久久夜色精品国产| 精品一久久香蕉国产线看播放| 久久综合五月丁香久久激情| 人人妻久久人人澡人人爽人人精品| 久久久精品国产Sm最大网站| 国产A级毛片久久久精品毛片| 久久久久夜夜夜精品国产| segui久久国产精品|