HarlonWang / HarlonWang/quickjs-wrapper
二进制字符串转到java后数据不一样
- Dominant language
- Java
- Stars
- 274
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Description
java
```java
public JSObject getMsg() {
JSObject data = context.createNewJSObject();
byte[] buffer = new byte[]{31, -117, 8, 0, 0, 0, 0, 0, 0, -1, 109, -112, 79, 79, -125, 64, 20, -60, -65, 11, -90, 55, -17, -20, -82, -91, -48, 27, -108, 63, -59, -12, -45, 98, -128, 10};
data.setProperty("msg", new String(buffer, StandardCharsets.UTF_8));
return data;
}
public void test(String text, int length) {
int len = text.length();
byte[] buffer = text.getBytes(StandardCharsets.UTF_8);
int len2 = buffer.length;
}
```
js
```js
const data = getMsg()
console.log(data)
test(data.msg, data.msg.length)
```
结果

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.