| 14 | private skipAtEnd: number = 0; |
| 15 | |
| 16 | constructor(private readonly msg: string) { |
| 17 | // From this point on Strings are not Unicode anymore! |
| 18 | const msgBinary = msg.split('').map(c => c.charCodeAt(0)); |
| 19 | const sb = new StringBuilder(); |
| 20 | for (let i = 0, c = msgBinary.length; i < c; i++) { |
| 21 | const ch = String.fromCharCode(msgBinary[i] & 0xff); |
| 22 | if (ch === '?' && msg.charAt(i) !== '?') { |
| 23 | throw new Error( |
| 24 | 'Message contains characters outside ISO-8859-1 encoding.' |
| 25 | ); |
| 26 | } |
| 27 | sb.append(ch); |
| 28 | } |
| 29 | this.msg = sb.toString(); // Not Unicode here! |
| 30 | this.shape = SymbolShapeHint.FORCE_NONE; |
| 31 | this.codewords = new StringBuilder(); |
| 32 | this.newEncoding = -1; |
| 33 | } |
| 34 | |
| 35 | public setSymbolShape(shape: SymbolShapeHint) { |
| 36 | this.shape = shape; |