Replies: 1 comment
-
I found a solution: // from char* pointer to String
final byte[] bytes = new byte[len];
req.get(0, bytes, 0, len);
String str = new String(bytes, StandardCharsets.UTF_8);
// Copy String to pointer
byte[] arr = json.getBytes();
int rspLen = arr.length;
var rspStr = libc.malloc(rspLen);
rspStr.put(0, arr, 0, rspLen); Is it idiomatic way? If so, why no official doc? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
For example, I have below c function:
Then in java:
Here
req
is a binary string, withlen
as total length.Then how to convert
req
intoString
for use?It seems that I could not use
req.getString(0)
, because it assumes thereq
is null-terminated c string?Beta Was this translation helpful? Give feedback.
All reactions