Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rawdata utf8 incompat #175

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions MiniScript-cpp/rdTest.ms
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,11 @@ testRawData = function
r.setUtf8 0, "hello world"
qa.assertEqual r.utf8(0), "hello w"

r = new RawData
qa.assertEqual r.utf8, null
r.resize 0
qa.assertEqual r.utf8, null
r.resize
r.resize 0
qa.assertEqual r.utf8, null
end function
3 changes: 3 additions & 0 deletions MiniScript-cpp/src/ShellIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,9 @@ static IntrinsicResult intrinsic_rawDataUtf8(Context *context, IntrinsicResult p
long nBytes = context->GetVar("bytes").IntValue();
const char *data = (const char *)rawDataGetBytes(self, offset, nBytes, rdnaNull);
if (!data) return IntrinsicResult::Null;
Value dataWrapper = self.Lookup(_handle);
RawDataHandleStorage *storage = (RawDataHandleStorage*)dataWrapper.data.ref;
if (storage->dataSize == 0) return IntrinsicResult::Null;
String result(data, nBytes);
return IntrinsicResult(result);
}
Expand Down