Skip to content

Commit

Permalink
Merge pull request #275 from NativeScript/slavchev/fix-issue-271
Browse files Browse the repository at this point in the history
fix issue #271
  • Loading branch information
Mihail Slavchev committed Nov 23, 2015
2 parents 1a28e19 + 38ef635 commit c33b18a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/jni/V8GlobalHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ Local<String> tns::ConvertToV8String(const jchar* data, int length)
Local<String> tns::ConvertToV8String(const string& s)
{
auto isolate = Isolate::GetCurrent();
return String::NewFromUtf8(isolate, s.c_str());
Local<String> str;
String::NewFromUtf8(isolate, s.c_str(), NewStringType::kNormal, s.length()).ToLocal(&str);
return str;
}

Local<String> tns::ConvertToV8String(const char *data, int length)
Expand Down
Binary file added test-app/assets/app/modules/moduleWithNullChar.js
Binary file not shown.
5 changes: 5 additions & 0 deletions test-app/assets/app/tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1886,4 +1886,9 @@ describe("Tests ", function () {
expect(exceptionCaught).toBe(true);
});

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

0 comments on commit c33b18a

Please sign in to comment.