Byte Lab · Level 5 of 5

Half a letter

The two tiles of 'é' arrive in two separate chunks, like data from a stream.

const { StringDecoder } = require('node:string_decoder');const chunk1 = Buffer.from([0xc3]);const chunk2 = Buffer.from([0xa9]);const glued = chunk1.toString() + chunk2.toString();console.log('broken ' + glued.includes('\uFFFD'));const decoder = new StringDecoder('utf8');console.log('first ' + JSON.stringify(decoder.write(chunk1)));console.log('second ' + (decoder.write(chunk2) === 'é'));

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…