将 v8::String 转换为 LPCWSTR? [英] Convert v8::String to LPCWSTR?
本文介绍了将 v8::String 转换为 LPCWSTR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我从运行时传递一个字符串值作为函数参数:
So I'm passing a string value as function argument from runtime:
Handle<Value> xObj::Whatever(const Arguments& args){ ... // etc.
args[0]
绝对应该是字符串:
if(!args[0]->IsString()) { ThrowException(... // etc.
既然我们有了它,我如何将它转换成一些有用的东西,比如 LPCWSTR、wchar_t、char[] 或其他什么?
Now that we have that, how do I convert it into something useful like LPCWSTR, wchar_t, char[] or whatever?
MessageBox(NULL, args[0], L"Your value, sir.",0); // no way
MessageBox(NULL, args[0]->ToString(), L"Your value, sir.",0); // also no
/// then how?
推荐答案
v8::String::Value(args[0])
can be cast to a uint16_t const*
code>,它要么是,要么可以转换为 LPCWSTR
.(这取决于编译器设置/Zc:wchar_t-
)
v8::String::Value(args[0])
can be casted to a uint16_t const*
, which either is, or can be casted to LPCWSTR
. (This depends on compiler setting /Zc:wchar_t-
)
这篇关于将 v8::String 转换为 LPCWSTR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文