win32 UNICODE 支持
原创muzizongheng 博主文章分类:自我心的 ©著作权
©著作权归作者所有:来自51CTO博客作者muzizongheng的原创作品,请联系作者获取转载授权,否则将追究法律责任
#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;
}
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
STM32的OLED
OLED显示,便于后期调试代码
IIC OLED -
Win32应用程序中文支持
Win32应用程序中文支持
#include 中文支持 应用程序 JAVA