Skip to content

Commit c33b18a

Browse files
author
Mihail Slavchev
committed
Merge pull request #275 from NativeScript/slavchev/fix-issue-271
fix issue #271
2 parents 1a28e19 + 38ef635 commit c33b18a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/jni/V8GlobalHelpers.cpp

Lines changed: 3 additions & 1 deletion
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

Lines changed: 5 additions & 0 deletions
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)