- uniapp 开发的app对接pda设备扫描,设备返回的数据为字节数组数据,uniapp如何将之转换为字符串,使用
let code = intent.getByteArrayExtra("data");
var byteArray = new Uint8Array(code);
var decoder = new TextDecoder("utf-8");
let decodedString = decoder.decode(byteArray);
console.log("扫码结果", decodedString);
code 为:[77,49,76,73,68,65,87,69,73,32,32,32,32,32,32,32,32,32,32,32,32,32,69,32,32,32,32,32,32,32,75,87,69,84,89,78,72,79,32,49,57,48,49,32,51,48,53,69,48,51,54,72,48,48,50,48,32,49,50,66,62,49,48,51,48,77,77,48,69,48,49,56,51,52,48,53,54,48,55,50,54,50,48,78,73,53,50,50,50,50,57,49,57,56,56,49,49,49,48,48,52,49,51,35,57,48,-26,-99,-114,-27,-92,-89,-28,-72,-70,35,57,49,-24,-76,-75,-23,-104,-77,35,57,50,-27,-92,-86,-27,-114,-97,35,57,51,50,48,52,35,57,52,49,48,58,49,48] 这段代码无法转换,启动debug模式又可以拿到数据,云打包之后又无法获取
x***@163.com
- 发布:2024-03-05 14:42
- 更新:2025-01-15 13:56
- 阅读:653