YGYOOO / ajax-interceptor

A chrome extension to modify the response of ajax requests. 修改ajax请求返回结果的chrome插件
https://chrome.google.com/webstore/detail/ajax-interceptor/nhpjggchkhnlbgdfcbgpdpkifemomkpg
915 stars 260 forks source link

Encoding problem in fetch #17

Open liaozhongwu opened 4 years ago

liaozhongwu commented 4 years ago

Thanks for the good idea of this repo.

I met a problem that chinese characters in response would be garbled, and I found that error happened when transferred string to arraybuffer below. const bufView = new Uint8Array(new ArrayBuffer(txt.length)); for (var i = 0; i < txt.length; i++) { bufView[i] = txt.charCodeAt(i); }

I tried to use TextEncoder to solve this problem. const encoder = new TextEncoder(); const view = encoder.encode(txt);

Could you reproduct it and provide with any other solution?

YGYOOO commented 4 years ago

Hi, sorry for the late reply. Could you show me the chinese characters that has been garbled?