google-chrome - 我发现 Chrome TextDecoder 错误了吗?
问题描述
测试: Linux 上的 Chrome 70.0.3538.110
错误:之前textDecoder.decode
调用失败会导致后续调用失败。
const log = console.log
let string = 'Hello ♥ world! ♥'
let textEncoder = new TextEncoder()
let bytes = textEncoder.encode(string)
let textDecoder = new TextDecoder('utf-8', {fatal: true})
try {
// Comment away this line and the code below will work
log(textDecoder.decode(new DataView(bytes.buffer, 0, 19)))
} catch (e) {
log('After this failed the next try will also fail')
}
log(textDecoder.decode(new DataView(bytes.buffer, 0, 20)))
解决方案
推荐阅读
- restsharp - 当请求可能返回不同对象时响应的反序列化
- python - Python itertools 生成带有替换的 powerset
- scala - Play 框架 2.7 中的配置服务器
- javascript - JavaScript 在 Accordion 展开和折叠时切换图标
- teradata - 具有易失性表和 CTE 的 Teradata 宏,用于将数据插入表中
- pytorch - 用pytorch DataLoader如何取两个ndarray(数据&标签)?
- ios - 错误域=NSCocoaErrorDomain 代码=1570
- javascript - Jquery 的 .before 和 .after 不适用于 Google Chrome 版本 49.0.2623.112
- r - 仅提取R中的月份和年份
- java - 如何将数据从firebase数据库传递到短信?