function writeString(bufferWriter, value) {
  const start = bufferWriter.index;
  const bytes = textEncoder.encode(value);
  const invalidChars = Array.from(value).filter(
    char =>
      char.charCodeAt(0) >= INVALID_STRING_CHARS_START &&
      char.charCodeAt(0) <= INVALID_STRING_CHARS_END,
  );
  if (invalidChars.length > 0) {
    throw Error(
      `Invalid string characters ${invalidChars.map(char => quote(char)).join(', ')} in string ${quote(value)} at index ${start}`,
    );
  }
  writeStringlike(bufferWriter, bytes, '"');
}
@param {import('./buffer-writer.js').BufferWriter} bufferWriter
@param {string} value