HarlonWang / HarlonWang/quickjs-wrapper

二进制字符串转到java后数据不一样

Open
#83 3 comments 0 reactions 0 assignees View on GitHub
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)
```
结果
![1729164328739](https://github.com/user-attachments/assets/3c8905c5-7747-4f5d-a308-f6a1806a250e)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.