2 u012023801 u012023801 于 2014.11.21 21:53 提问

google V8 执行脚本返回中文字符串乱码

Isolate* isolate = Isolate::New();
{
Isolate::Scope isolate_scope(isolate);

    HandleScope handle_scope(isolate);

    Local<Context> context = Context::New(isolate);

    Context::Scope context_scope(context);

    Local<String> source = String::NewFromUtf8(isolate, "'好'");

    Local<Script> script = Script::Compile(source);

    Local<Value> result = script->Run();

    String::Utf8Value utf8(result);

    printf("%s\n", *utf8);
}
Csdn user default icon
上传中...
上传图片
插入图片