import * as assert from 'assert' ; import { StringUtils } from '@zxing/library' ; import { CharacterSetECI } from '@zxing/library' ; describe ( 'StringUtils' , ( ) => { it ( 'testShortShiftJIS_1' , ( ) => { doTest ( Uint8Array . from ( [ 0x8b , 0xe0 , 0x8b , 0x9b ] ) , CharacterSetECI . SJIS . getName ( ) ) ; } ) ; it ( 'testShortISO88591_1' , ( ) => { doTest ( Uint8Array . from ( [ 0x62 , 0xe5 , 0x64 ] ) , CharacterSetECI . ISO8859_1 . getName ( ) ) ; } ) ; it ( 'testMixedShiftJIS_1' , ( ) => { doTest ( Uint8Array . from ( [ 0x48 , 0x65 , 0x6c , 0x6c , 0x6f , 0x20 , 0x8b , 0xe0 , 0x21 ] ) , 'SJIS' ) ; } ) ; function doTest ( bytes , charsetName ) { const guessedName = StringUtils . guessEncoding ( bytes , null ) ; assert . strictEqual ( guessedName , charsetName ) ; } } ) ;