evaluateJavaScript 执行结果中有乱码
@bbssyyuui is already working on this.
Since Apr 6, 2022.
Assessment
This issue has not been assessed yet.
Description
描述
master 分支

Hummer version:
master 分支源码依赖
复现步骤
设备 samsung-G532F,android 系统版本 5.0
1.执行js逻辑
2.结果中出现乱码
预期结果
结果正常
样例代码、屏幕截图或者仓库链接
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_home);
if (context == null) {
context = JSCContext.create();
((TextView) findViewById(R.id.info)).setText("context id is" + context.context);
}
findViewById(R.id.test).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
String js = readFileFromAssets(getApplicationContext(), "HelloWorld.js");
context.evaluateJavaScript(js);
} catch (Exception ex) {
Log.e(TAG, ex.getLocalizedMessage());
}
Object res = context.evaluateJavaScript("test()");
Log.i(TAG, "res is " + res);
((TextView) findViewById(R.id.res)).setText("context id is" + context.context + "\n" + res.toString());
}
});
}
public String readFileFromAssets(Context context, String fileName) throws IOException {
if (null == context || null == fileName) return null;
AssetManager am = context.getAssets();
InputStream input = am.open(fileName);
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = input.read(buffer)) != -1) {
output.write(buffer, 0, len);
}
output.close();
input.close();
return output.toString();
}
helloword.js
function test() {
let data = { "path": "/api/v4/recommend/recommend", "method": "GET", "params": ["bundle=daily_discover_main", "offset=0", "latitude=", "longitude=", "limit=20"] }
return JSON.stringify(data);
}
- Dominant language
- Objective-C
- Stars
- 1.4k
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from didi/Hummer
-
支持svg图吗?Openenhancement Needs: Triage 🔍
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
T i t li leOpenbug Needs: Triage 🔍
Difficulty 5/5 Over a week Newbie friendliness 1/100
-
升级yoga3(yoga2)后,scroller 在不设置size 时,两端大小表现不一致May be free again @yFeii claimed this 860 days ago, and no pull request is open. Openbug Needs: Triage 🔍
-
bug Needs: Triage 🔍
Difficulty 4/5 3-5 days Newbie friendliness 20/100
-
bug Needs: Triage 🔍
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
A heading containing `$` or `\` is mangled in the table of contentsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
schuyler/macdown3000#693 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
yetanotherbrowser/yab#1062 ·
Maintainers usually reply within 1 day
-
Peek: the card's top-bar buttons can miss a press while the card is pinchedPossibly taken @mjkang-estrella claimed this 2 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ardia-browser/ardia#3087 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
darlinghq/darling#2335 · 1 comment ·
Maintainers usually reply within 1 day
-
Cocoa
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
getsentry/sentry-cocoa#9693 · 1 comment ·
Maintainers usually reply within 1 day