将“const wchar_t *”转换为“unsigned char *” [英] Convert a 'const wchar_t *' to 'unsigned char *'
本文介绍了将“const wchar_t *”转换为“unsigned char *”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C ++中可以将const wchar_t *转换为unsigned char *?
In C++ is it possible to convert a 'const wchar_t *' to 'unsigned char *'?
我如何做?
wstring dirName;
unsigned char* dirNameA = (unsigned char*)dirName.c_str();
// I am creating a hash from a string
hmac_sha256_init( hash, (unsigned char*)dirName.c_str(), (dirName.length)+1 );
推荐答案
由于您使用的是WinAPI, =http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130%28v=vs.85%29.aspx =nofollow> WideCharToMultiByte
。
Since you're using WinAPI, use WideCharToMultiByte
.
这篇关于将“const wchar_t *”转换为“unsigned char *”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文