字符串到字符串^会话 [英] string to string ^ converstion
本文介绍了字符串到字符串^会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将ascii字符串转换为unicode字符串,所以你能给我一个小例子吗?
在此先感谢...
i want to convert ascii string to unicode string so can you just give me small example
Thanks in advance...
推荐答案
您可以在非Unicode项目中使用A2W
宏:):
You could useA2W
macro in a non-unicode project :) :
#include <AtlConv.h>
{
char* pchTest("test");
USES_CONVERSION;
// Please note: pwchResult is an on-stack pointer !
WCHAR* pwchResult(A2W(pchTest));
}
...或者只是Unicode项目中的CString
:
...or just a CString
in a unicode project:
{
char* pchTest("test");
CString cszResult(pchTest);
}
我喜欢将swprintf用于此类事情:
I like using swprintf for that sort of thing:
swprintf_s( UnicodeStr, LenOfUnicodeString, L"%S", ASCIIStr );
请注意,%S中的"S"必须为大写字母-这是进行转换的地方:)
please note, that the ''S'' in %S has to be capital - this is where the conversion happens :)
这篇关于字符串到字符串^会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文