Gozala / Gozala/web-encoding

@zxing/text-encoding (and this package) are wrong on latin1 and ascii

Open
#36 2 comments 0 reactions 0 assignees View on GitHub
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.