File tree Expand file tree Collapse file tree 4 files changed +12
-13
lines changed Expand file tree Collapse file tree 4 files changed +12
-13
lines changed Original file line number Diff line number Diff line change 1
1
import { Stream } from "../../common/Stream" ;
2
2
import { decoderError } from "../../encoding/encodings" ;
3
3
import { finished } from "../../encoding/finished" ;
4
- import { index } from "../../encoding/indexes" ;
5
4
import { end_of_stream , isASCIIByte } from "../../encoding/terminology" ;
6
5
7
6
/**
@@ -14,7 +13,7 @@ export class SingleByteDecoder {
14
13
15
14
readonly fatal : boolean ;
16
15
17
- constructor ( index : Array < number > , options : { fatal : boolean ; } ) {
16
+ constructor ( private readonly index : Array < number > , options : { fatal : boolean ; } ) {
18
17
this . fatal = options . fatal ;
19
18
}
20
19
@@ -37,10 +36,10 @@ export class SingleByteDecoder {
37
36
38
37
// 3. Let code point be the index code point for byte − 0x80 in
39
38
// index single-byte.
40
- const code_point = index [ bite - 0x80 ] ;
39
+ const code_point = this . index [ bite - 0x80 ] ;
41
40
42
41
// 4. If code point is null, return error.
43
- if ( code_point === null )
42
+ if ( ! code_point )
44
43
return decoderError ( this . fatal ) ;
45
44
46
45
// 5. Return a code point whose value is code point.
Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ export class TextDecoder {
178
178
if ( result === finished )
179
179
break ;
180
180
181
- if ( result !== null ) {
181
+ if ( result ) {
182
182
if ( Array . isArray ( result ) )
183
183
output . push . apply ( output , /**@type {!Array.<number> }*/ ( result ) ) ;
184
184
else
@@ -196,7 +196,7 @@ export class TextDecoder {
196
196
result = this . _decoder . handler ( input_stream , input_stream . read ( ) ) ;
197
197
if ( result === finished )
198
198
break ;
199
- if ( result === null )
199
+ if ( ! result )
200
200
continue ;
201
201
if ( Array . isArray ( result ) )
202
202
output . push . apply ( output , /**@type {!Array.<number> }*/ ( result ) ) ;
Original file line number Diff line number Diff line change @@ -386,8 +386,8 @@ test(function() {
386
386
assert_array_equals ( [ ] . slice . call ( encoder . encode ( 0 ) ) , [ 48 ] ) ;
387
387
} , 'encode() called with falsy arguments (polyfill bindings)' ) ;
388
388
389
- // test(function() {
390
- // // Regression test for https://github.com/inexorabletash/text-encoding/issues/59
391
- // assert_array_equals(
392
- // new TextEncoding.TextDecoder('windows-1255').decode(new Uint8Array([0xCA])), '\u05BA');
393
- // }, 'windows-1255 map 0xCA to U+05BA');
389
+ test ( function ( ) {
390
+ // Regression test for https://github.com/inexorabletash/text-encoding/issues/59
391
+ assert_array_equals (
392
+ new TextEncoding . TextDecoder ( 'windows-1255' ) . decode ( new Uint8Array ( [ 0xCA ] ) ) , '\u05BA' ) ;
393
+ } , 'windows-1255 map 0xCA to U+05BA' ) ;
Original file line number Diff line number Diff line change @@ -399,10 +399,10 @@ describe('Miscellaneous tests', () => {
399
399
assert_array_equals ( [ ] . slice . call ( encoder . encode ( 0 ) ) , [ 48 ] ) ;
400
400
} ) ;
401
401
402
- it . skip ( 'windows-1255 map 0xCA to U+05BA' , ( ) => {
402
+ it ( 'windows-1255 map 0xCA to U+05BA' , ( ) => {
403
403
// Regression test for https://github.com/inexorabletash/text-encoding/issues/59
404
404
assert_equals (
405
- new TextDecoder ( 'windows-1255' ) . decode ( new Uint8Array ( [ 0xCD ] ) ) ,
405
+ new TextDecoder ( 'windows-1255' ) . decode ( new Uint8Array ( [ 0xCA ] ) ) ,
406
406
'\u05BA'
407
407
) ;
408
408
} ) ;
You can’t perform that action at this time.
0 commit comments