如何将V8::Value转换为二进制字符串

How to convert V8::Value to binary string?

本文关键字:二进制 字符串 转换 Value V8      更新时间:2023-10-16

I post buffer(nodejs buffer) in function:

Handle<Value> some::encrypt_buf (const Arguments& args) {
    String::AsciiValue abuf(args[0]->ToString());
    cout<<abuf.length()<<endl;
    char *buf=*abuf;
    ...
}
如果buffer中有像这样的字符,

会得到错误的长度。如何获得所有二进制字符abuf和正确的长度()?也许存在最好的方式直接转换V8::值char*和长度?

我决定这么做

#include <node_buffer.h>
...
Handle<Value> some::encrypt_buf (const Arguments& args) {
    int len=node::Buffer::Length(args[0]->ToObject());
    char *buf=Node::Buffer::Data(args[0]->ToObject());
    ...
}

为什么没有这个的官方文档?: - https://www.google.ru/webhp?q=%22node:缓冲::数据% 22 +网站:nodejs.org