zoukankan      html  css  js  c++  java
  • win32 UNICODE 支持


    #include <string>

    #ifdef _UNICODE
    #define tstring std::wstring
    #define __T(quote) L##quote
    #else
    #define tstring string
    #define __T(quote) quote
    #endif

    #define _T(quote) __T(quote)   
    #define _TEXT(quote) __T(quote) 
    #define TEXT(quote) __T(quote)




                    std::string T2A(const tstring& sInput)
                    {
    #ifdef _UNICODE
                                    return std::string(sInput.begin(), sInput.end());
    #else
                                    return sInput;
    #endif
                    };

                    tstring A2T(const std::string& sInput)
                    {
    #ifdef _UNICODE
                                    return tstring(sInput.begin(), sInput.end());
    #else
                                    return sInput;
    #endif
                    };



    int replace_all(tstring& str const tstring& pattern const tstring& newpat)
    {
                    int count = 0;
                    const size_t nsize = newpat.size();
                    const size_t psize = pattern.size();

                    for(size_t pos = str.find(pattern, 0); 
                                    pos != tstring::npos;
                                    pos = str.find(pattern,pos + nsize))
                    {
                                    str.replace(pos, psize, newpat);
                                    count++;
                    }

                    return count;
    }
      
  • 相关阅读:
    团队项目冲刺阶段一(6)
    每日日报
    每日日报
    每日日报
    每日日报
    每日日报
    每日日报
    每日日报
    梦断代码读后感
    每日日报
  • 原文地址:https://www.cnblogs.com/muzizongheng/p/3167319.html
Copyright © 2011-2022 走看看