I have an ArrayBuffer in JS like so:
[0 1 2 3 ... 127 128 129 ... 255]
I see from the emscripten documents that ArrayBuffer is bound to std::string.
My emscripten code is
void set(const std::string& buffer);
EMSCRIPTEN_BINDINGS(...)
{
function("set", &set);
}
When I call this from JS
set(buffer) // where buffer is an ArrayBuffer with [0 1 2 3 ... 127 128 129 ... 255] values
accessing the std::string in a for loop char by char using
std::cout << static_cast(buffer[i]) << std::endl;
yields
0 1 2 3 ... 127 -127, -126 -125 ... 1
Its understandable, since thats how chars beyond 127 are interpreted in JS, and it seems JS is first converting the ArrayBuffer to a string and passing it to emscripten. I however thought the documentation said ArrayBuffer -> string binding is supported, so I would expect the string c++ values to contain [0 .. 255].
Any suggestions please? Else I have to send an integer one by one from the arraybuffer to emscripten.
I have an ArrayBuffer in JS like so:
[0 1 2 3 ... 127 128 129 ... 255]
I see from the emscripten documents that ArrayBuffer is bound to std::string.
My emscripten code is
void set(const std::string& buffer);
EMSCRIPTEN_BINDINGS(...)
{
function("set", &set);
}
When I call this from JS
set(buffer) // where buffer is an ArrayBuffer with [0 1 2 3 ... 127 128 129 ... 255] values
accessing the std::string in a for loop char by char using
std::cout << static_cast(buffer[i]) << std::endl;
yields
0 1 2 3 ... 127 -127, -126 -125 ... 1
Its understandable, since thats how chars beyond 127 are interpreted in JS, and it seems JS is first converting the ArrayBuffer to a string and passing it to emscripten. I however thought the documentation said ArrayBuffer -> string binding is supported, so I would expect the string c++ values to contain [0 .. 255].
Any suggestions please? Else I have to send an integer one by one from the arraybuffer to emscripten.