writeVarString = (encoder, str) => {
  const encodedString = unescape(encodeURIComponent(str));
  const len = encodedString.length;
  writeVarUint(encoder, len);

  for (let i = 0; i < len; i++) {
    write(encoder,
    /** @type {number} */
    encodedString.codePointAt(i));
  }
}
Write a variable length string.

@function
@param {Encoder} encoder
@param {String} str The string that is to be encoded.