@zxing/text-encoding (and this package) are wrong on latin1 and ascii
- Dominant language
- JavaScript
- Stars
- 10
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
First of all, non-utf8 encodings are not loaded at all.
But if loaded per instruction at https://www.npmjs.com/package/@zxing/text-encoding, the lib behaves like this :
```js
test('ascii', async () => {
const { TextDecoder } = await import('web-encoding')
const td = new TextDecoder('ascii')
const str = td.decode(Uint8Array.of(0x80, 0x9f))
console.log([td.encoding, str, str.codePointAt(0), str.codePointAt(1)])
})
test('latin1', async () => {
const { TextDecoder } = await import('web-encoding')
const td = new TextDecoder('latin1')
const str = td.decode(Uint8Array.of(0x80, 0x9f))
console.log([td.encoding, str, str.codePointAt(0), str.codePointAt(1)])
})
test('windows-1252', async () => {
const { TextDecoder } = await import('web-encoding')
const td = new TextDecoder('windows-1252')
const str = td.decode(Uint8Array.of(0x80, 0x9f))
console.log([td.encoding, str, str.codePointAt(0), str.codePointAt(1)])
})
})
```
React Native:
```
[ 'iso-8859-1', '', 128, 159 ]
[ 'iso-8859-1', '', 128, 159 ]
[ 'windows-1252', '€Ÿ', 8364, 376 ]
```
Everywhere else (and per spec):
```
[ 'windows-1252', '€Ÿ', 8364, 376 ]
[ 'windows-1252', '€Ÿ', 8364, 376 ]
[ 'windows-1252', '€Ÿ', 8364, 376 ]
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.