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


            久久久久久国产精品无码超碰| 久久国产精品免费| 亚洲色欲久久久久综合网| 久久99精品国产麻豆婷婷| 久久久久亚洲AV无码专区桃色| 一级a性色生活片久久无少妇一级婬片免费放 | 久久午夜电影网| 久久国产V一级毛多内射| 欧美伊人久久大香线蕉综合| 久久午夜羞羞影院免费观看| 国产AⅤ精品一区二区三区久久| 人妻丰满?V无码久久不卡| 国产精品美女久久久m| 久久精品无码一区二区三区日韩 | 国产精品免费福利久久| 欧美午夜精品久久久久久浪潮| 亚洲国产欧美国产综合久久| 久久99精品国产麻豆不卡| 国产综合久久久久| 久久久久亚洲国产| 国产精品综合久久第一页| 久久久婷婷五月亚洲97号色| 久久久久亚洲?V成人无码| 精品久久久噜噜噜久久久| 久久久久国产精品人妻| 欧美国产成人久久精品| 99久久免费国产精品| 精品少妇人妻av无码久久| 精品一二三区久久aaa片| 久久天天躁狠狠躁夜夜2020| 一级做a爰片久久毛片人呢| 九九久久99综合一区二区| 日韩久久久久久中文人妻| 久久人人爽人人人人爽AV| 区亚洲欧美一级久久精品亚洲精品成人网久久久久| 久久久久久九九99精品| 粉嫩小泬无遮挡久久久久久| 人妻精品久久无码区| 久久久无码精品亚洲日韩按摩| 久久精品国产亚洲av麻豆色欲| 久久人做人爽一区二区三区 |