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

            導航

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

            統計

            常用鏈接

            留言簿(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 深邃者 閱讀(164) 評論(0)  編輯 收藏 引用

            狠狠久久综合| 久久九九久精品国产| 久久久久久久久久免免费精品| 久久免费视频网站| 久久久黄片| 日产精品久久久一区二区| 色综合合久久天天综合绕视看| 精品水蜜桃久久久久久久| 国内精品综合久久久40p| 97久久超碰国产精品旧版| 久久久久国产一区二区三区| 久久国产AVJUST麻豆| 国产成人无码精品久久久久免费| 久久精品亚洲男人的天堂| 欧美丰满熟妇BBB久久久| 色综合久久88色综合天天 | 久久精品夜夜夜夜夜久久| 性做久久久久久久久老女人| 国产精品无码久久综合| 2020国产成人久久精品| 国产精品99久久久久久www| 久久久精品2019免费观看| 国产一区二区久久久| 欧美精品一本久久男人的天堂| 国产精品久久久久a影院| 久久精品亚洲男人的天堂 | 久久久久久九九99精品| 欧美成a人片免费看久久| 久久精品国产91久久麻豆自制| 97视频久久久| 深夜久久AAAAA级毛片免费看 | 国产精品久久久久jk制服| 久久亚洲中文字幕精品一区| 久久综合亚洲色HEZYO国产 | 性做久久久久久久久久久| 久久精品女人天堂AV麻| 嫩草影院久久99| 91秦先生久久久久久久| 91久久香蕉国产熟女线看| 久久99精品久久久久久秒播| 国产精品九九久久精品女同亚洲欧美日韩综合区 |