C++ Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
//窄字符转宽字符
void ConvertA2W(wchar_t* the_strw, char* the_str, int len)//注意:默认the_strw和the_str有足够长度的内存,大于len字符;
{
    TCHAR* old_locale = _tcsdup( _tsetlocale(LC_ALL,NULL) ); 
    setlocale(LC_ALL, ".936");
    size_t nSize = len + ;
    memset(the_strw, , sizeof(wchar_t)*len);

size_t i_tem;
    mbstowcs_s(&i_tem, the_strw, nSize, the_str, nSize);
    _tsetlocale( LC_ALL, old_locale );                  //还原语言区域的设置 
    free( old_locale );                                 //还原区域设定
}
//宽字符转窄字符
void ConvertW2A(wchar_t* the_strw, char* the_str, int len)//注意:默认the_strw和the_str有足够长度的内存,大于len字符;
{
    TCHAR* old_locale = _tcsdup( _tsetlocale(LC_ALL,NULL) ); 
    setlocale(LC_ALL, ".936");
    size_t nSize = len + ;
    memset(the_str, , sizeof(char)*len);

size_t i_tem;
    wcstombs_s(&i_tem, the_str, nSize, the_strw, nSize);
    _tsetlocale( LC_ALL, old_locale );                  //还原语言区域的设置 
    free( old_locale );                                 //还原区域设定
}

最新文章

  1. Python(五)模块
  2. 安卓开发之activity详解(sumzom)
  3. 网络编程3--毕向东java基础教程视频学习笔记
  4. 全网扫描扫描10000端口后的优化脚本&域名列表指定端口的批量测试
  5. Core Java - 流(Stream) - 字节流和字符流(一)
  6. python基础使用
  7. 51nod1262 扔球
  8. objective-c 加号 减号 - +
  9. RMAN连接及简单操作
  10. 成都传智职工high翻竞赛场
  11. log4net 开箱即用
  12. Mybatis初学笔记
  13. matolop画图
  14. No Spring WebApplicationInitializer types detected on classpath 问题的一种解决办法
  15. LFYZ-OJ ID: 1020 过河卒(NOIP2002)
  16. Exception:两个类具有相同的 XML 类型名称,请使用 @XmlType.name 和 @XmlType.namespace 为类分配不同的名称
  17. xpath 的使用
  18. hihoCoder 1116 计算(线段树)
  19. openx 添加新表和据库表和字段
  20. lavarel模板引擎blade学习

热门文章

  1. SVN:This client is too old to work with working copy…解决方法
  2. 08-spring学习-annotation配置
  3. hibernate session的load和get方法
  4. ROC
  5. X86服务器、小型机、大型机、塔式、机架式、刀片式服务器、工作站
  6. Sphinx-安装和配置
  7. PHP-PHP5.3及以上版本中检查json格式的方法
  8. Image.Save出错 GDI 一般错误
  9. 【转载】XGBoost调参
  10. Shell 基础笔记