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;
    }
      
  • 相关阅读:
    印刷行业合版BOM全阶维护示例
    C#实现WinForm禁止最大化、最小化、双击标题栏、双击图标等操作的方法
    EasyUI Tree节点拖动到指定容器
    Excel GET.DOCUMENT说明
    Excel GET.CELL说明
    ExecuteExcel4Macro (宏函数)使用说明
    MSSQL:查看所有触发器信息的命令
    SQL Server 2008作业失败:无法确定所有者是否有服务器访问权限
    Cocoa History
    Working with Methods
  • 原文地址:https://www.cnblogs.com/muzizongheng/p/3167319.html
Copyright © 2011-2022 走看看