import { toCharCode } from 'src/utils/strings' ; const pdfDocEncodingToUnicode = new Uint16Array ( 256 ) ; for ( let idx = 0 ; idx < 256 ; idx ++ ) { pdfDocEncodingToUnicode [ idx ] = idx ; } pdfDocEncodingToUnicode [ 0x16 ] = toCharCode ( '\u0017' ) ; pdfDocEncodingToUnicode [ 0x18 ] = toCharCode ( '\u02D8' ) ; pdfDocEncodingToUnicode [ 0x19 ] = toCharCode ( '\u02C7' ) ; pdfDocEncodingToUnicode [ 0x1a ] = toCharCode ( '\u02C6' ) ; pdfDocEncodingToUnicode [ 0x1b ] = toCharCode ( '\u02D9' ) ; pdfDocEncodingToUnicode [ 0x1c ] = toCharCode ( '\u02DD' ) ; pdfDocEncodingToUnicode [ 0x1d ] = toCharCode ( '\u02DB' ) ; pdfDocEncodingToUnicode [ 0x1e ] = toCharCode ( '\u02DA' ) ; pdfDocEncodingToUnicode [ 0x1f ] = toCharCode ( '\u02DC' ) ; pdfDocEncodingToUnicode [ 0x7f ] = toCharCode ( '\uFFFD' ) ; pdfDocEncodingToUnicode [ 0x80 ] = toCharCode ( '\u2022' ) ; pdfDocEncodingToUnicode [ 0x81 ] = toCharCode ( '\u2020' ) ; pdfDocEncodingToUnicode [ 0x82 ] = toCharCode ( '\u2021' ) ; pdfDocEncodingToUnicode [ 0x83 ] = toCharCode ( '\u2026' ) ; pdfDocEncodingToUnicode [ 0x84 ] = toCharCode ( '\u2014' ) ; pdfDocEncodingToUnicode [ 0x85 ] = toCharCode ( '\u2013' ) ; pdfDocEncodingToUnicode [ 0x86 ] = toCharCode ( '\u0192' ) ; pdfDocEncodingToUnicode [ 0x87 ] = toCharCode ( '\u2044' ) ; pdfDocEncodingToUnicode [ 0x88 ] = toCharCode ( '\u2039' ) ; pdfDocEncodingToUnicode [ 0x89 ] = toCharCode ( '\u203A' ) ; pdfDocEncodingToUnicode [ 0x8a ] = toCharCode ( '\u2212' ) ; pdfDocEncodingToUnicode [ 0x8b ] = toCharCode ( '\u2030' ) ; pdfDocEncodingToUnicode [ 0x8c ] = toCharCode ( '\u201E' ) ; pdfDocEncodingToUnicode [ 0x8d ] = toCharCode ( '\u201C' ) ; pdfDocEncodingToUnicode [ 0x8e ] = toCharCode ( '\u201D' ) ; pdfDocEncodingToUnicode [ 0x8f ] = toCharCode ( '\u2018' ) ; pdfDocEncodingToUnicode [ 0x90 ] = toCharCode ( '\u2019' ) ; pdfDocEncodingToUnicode [ 0x91 ] = toCharCode ( '\u201A' ) ; pdfDocEncodingToUnicode [ 0x92 ] = toCharCode ( '\u2122' ) ; pdfDocEncodingToUnicode [ 0x93 ] = toCharCode ( '\uFB01' ) ; pdfDocEncodingToUnicode [ 0x94 ] = toCharCode ( '\uFB02' ) ; pdfDocEncodingToUnicode [ 0x95 ] = toCharCode ( '\u0141' ) ; pdfDocEncodingToUnicode [ 0x96 ] = toCharCode ( '\u0152' ) ; pdfDocEncodingToUnicode [ 0x97 ] = toCharCode ( '\u0160' ) ; pdfDocEncodingToUnicode [ 0x98 ] = toCharCode ( '\u0178' ) ; pdfDocEncodingToUnicode [ 0x99 ] = toCharCode ( '\u017D' ) ; pdfDocEncodingToUnicode [ 0x9a ] = toCharCode ( '\u0131' ) ; pdfDocEncodingToUnicode [ 0x9b ] = toCharCode ( '\u0142' ) ; pdfDocEncodingToUnicode [ 0x9c ] = toCharCode ( '\u0153' ) ; pdfDocEncodingToUnicode [ 0x9d ] = toCharCode ( '\u0161' ) ; pdfDocEncodingToUnicode [ 0x9e ] = toCharCode ( '\u017E' ) ; pdfDocEncodingToUnicode [ 0x9f ] = toCharCode ( '\uFFFD' ) ; pdfDocEncodingToUnicode [ 0xa0 ] = toCharCode ( '\u20AC' ) ; pdfDocEncodingToUnicode [ 0xad ] = toCharCode ( '\uFFFD' ) ; param bytes export const pdfDocEncodingDecode = ( bytes ) : string => { const codePoints = new Array ( bytes . length ) ; for ( let idx = 0 , len = bytes . length ; idx < len ; idx ++ ) { codePoints [ idx ] = pdfDocEncodingToUnicode [ bytes [ idx ] ] ; } return String . fromCodePoint ( ... codePoints ) ; } ;