(s: string)
| 194 | } |
| 195 | |
| 196 | public writeUTFBytes(s: string) { |
| 197 | const escstr = encodeURIComponent(s); |
| 198 | const binstr = escstr.replace(/%([0-9A-F]{2})/g, function(match, p1) { |
| 199 | return String.fromCharCode(parseInt('0x' + p1)); |
| 200 | }); |
| 201 | |
| 202 | this.ensureWriteableSpace(4 + binstr.length); |
| 203 | this.writeInt(binstr.length); |
| 204 | for (let i = 0; i < binstr.length; i++) { |
| 205 | this.writeUnsignedByte(binstr.charCodeAt(i)); //todo: there are probably faster ways to do this |
| 206 | } |
| 207 | if (binstr.length % 4) { |
| 208 | const paddingbytes: number = binstr.length % 4; |
| 209 | for (let i = 0; i < paddingbytes; i++) { |
| 210 | this.writeUnsignedByte(0); |
| 211 | } |
| 212 | |
| 213 | } |
| 214 | return binstr.length; |
| 215 | } |
| 216 | |
| 217 | public readInt(): number { |
| 218 | const data: DataView = new DataView(this.arraybytes); |
nothing calls this directly
no test coverage detected