将LPWSTR转换为v8::String
Convert LPWSTR to v8::String
LPWSTR dscStr = "TEST STRING AAAAAA";
char buffer[5000];
wcstombs(buffer, dscStr, sizeof(dscStr));
return scope.Close(String::New(buffer)); // FAILED
我需要将LPWSTR(或LPCWSTR)转换为v8::String.
你发布的代码甚至不应该编译,因为你试图将char const *
分配给wchar_t *
。
这应该工作(我不知道任何关于v8::String
,所以我假设最后一行的构造函数调用是正确的)
LPCWSTR dscStr = L"TEST STRING AAAAAA";
// LPCWSTR is an alias for wchar_t const *
// The L before the string literal indicates it is a wide string literal
char buffer[5000];
wcstombs( buffer, dscStr, wcslen(dscStr) );
// Need wcslen to compute the length of the string
return scope.Close(String::New(buffer));
相关文章:
- cppcheck在const std::string[]上引发警告
- 将std::string传递给WriteConsole API
- 为std::string的某个索引赋值
- std中有类似find_last_of的函数,而string中没有
- 使用 std::string () const 函数启动线程或未来
- 使用char类型将decimal转换为string,将string转换为decimal
- 示例外壳应用程序显示的 V8 "segmentation fault (core dumped)"错误
- 迭代和比较映射<字符串、矢量<string>> c++ 中的值
- 当我们进行一些操作时,应该使用什么'std::string'或'std::stringstream'?
- 将向量解析<string>为字符串
- 'string.assign(string.data(), 5)' 是明确定义的还是 UB?
- 在 G++ v8.2.0 中使用 std::experimental::可选
- 如何更改大小(std::string)
- "string.h"在构建适用于iOS的qt应用程序中找不到消息
- 如何将v8::String转换为const char*
- 如何将 std::string 转换为 v8 的本地<string>
- *v8::String::Utf8Value(args[0]->ToString()) 不返回 node 的字符串.js addon 参数
- 为什么在v8::Scope之前创建新的v8::Array会导致分割错误,而v8::String和v8::Function
- V8回调,用Number代替String
- 将LPWSTR转换为v8::String