WinCe和Windows Mobile下的Unicode和ANSI字符串转换的方法

简介:

在WinCe和Windows Mobile下字符串是unicode,所以在开发native code的时候,特别是注意字符串的转换,下面是比较简单的字符串转换方法。记录下来,以便查找。

复制代码
char  szA[ 100 ];  //  ANSI
WCHAR szW[ 200 ];  //  Unicode

//  regular call of sprintf: all strings are in ANSI
sprintf(szA,  " %s " " ANSI Str " );

//  convert string from Unicode into ANSI
sprintf(szA,  " %S " " Unicode Str " );

//  regular call swprintf. All string are in Unicode
swprintf(szW, L " %s " , L " Unicode Str " );

//  convert string from ANSI into Unicode
swprintf(szW, L " %S " " ANSI Str " );
复制代码

 


复制代码
// convert CString(Unicode) to std::string
CString str  =   " mel " ;
std::
string  city  =  CT2CA(str);

// convert std::string to CString(Unicode)
std:: string  str  =   " AA " ;
CString cstr 
=  CComBSTR(str);
复制代码

 

更深入的请参考 

一文讲清楚Windows Mobile和Wince(Windows Embedded CE)的字符集问题


 


    本文转自Jake Lin博客园博客,原文链接:http://www.cnblogs.com/procoder/archive/2009/04/02/Convert_String.html,如需转载请自行联系原作者



相关文章
|
4月前
|
安全 Windows
windows11 永久关闭windows defender的方法
windows11 永久关闭windows defender的方法
359 2
|
4月前
|
Ubuntu Linux Windows
两种Ubuntu和Windows互相共享文件夹的方法
两种Ubuntu和Windows互相共享文件夹的方法
|
1天前
|
Java 程序员 Windows
【windows自带exe】使用`findstr.exe`来搜索包含某个字符串的文件
【windows自带exe】使用`findstr.exe`来搜索包含某个字符串的文件
7 0
|
9天前
|
Windows
Windows 程序自启动实现方法详解
Windows 程序自启动实现方法详解
25 0
|
1月前
|
存储 人工智能 资源调度
【windows批处理batch】.bat文件 字符串处理相关操作(字符串定义、分割、拼接、替换、切片、查找)
【windows批处理batch】.bat文件 字符串处理相关操作(字符串定义、分割、拼接、替换、切片、查找)
|
2月前
|
安全 Windows
关闭Windows自动更新的6种方法
关闭Windows自动更新的6种方法
196 0
|
3月前
|
Windows
不让Windows显示语言栏“中”“英”字符的一种方法
【2月更文挑战第6天】本文介绍在Windows 11操作系统中,将任务栏右下角的语言栏的“中”、“英”标识加以隐藏、消除的一种或许可行的方法~
不让Windows显示语言栏“中”“英”字符的一种方法
|
5月前
|
定位技术 Windows
Windows电脑删除文件时确认是否删除文件的提示对话框的取消显示方法
Windows电脑删除文件时确认是否删除文件的提示对话框的取消显示方法
|
1月前
|
Linux Windows
Windows Server 下文件同步
Windows Server 下文件同步
19 0
|
2天前
|
开发框架 .NET 数据库
修改windows server 2008 时间和日期格式
修改windows server 2008 时间和日期格式

热门文章

最新文章