Skip to content

Commit bca7250

Browse files
author
Mihail Slavchev
committed
fix issue #271
1 parent 2ed1eaf commit bca7250

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/jni/V8GlobalHelpers.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ Local<String> tns::ConvertToV8String(const jchar* data, int length)
3333
Local<String> tns::ConvertToV8String(const string& s)
3434
{
3535
auto isolate = Isolate::GetCurrent();
36-
return String::NewFromUtf8(isolate, s.c_str());
36+
Local<String> str;
37+
String::NewFromUtf8(isolate, s.c_str(), NewStringType::kNormal, s.length()).ToLocal(&str);
38+
return str;
3739
}
3840

3941
Local<String> tns::ConvertToV8String(const char *data, int length)
29 Bytes
Binary file not shown.

test-app/assets/app/tests/tests.js

+5
Original file line numberDiff line numberDiff line change
@@ -1886,4 +1886,9 @@ describe("Tests ", function () {
18861886
expect(exceptionCaught).toBe(true);
18871887
});
18881888

1889+
it("should load module with null char in it", function () {
1890+
var text = require("../modules/moduleWithNullChar").text;
1891+
var s = "Hello world";
1892+
expect(text.length).toBe(s.length);
1893+
});
18891894
});

0 commit comments

Comments
 (0)