std::string forgivingBase64Encode(std::string_view data) {
  int length = data.length();
  std::string output = "";
  // The Base64 version of a string will be at least 133% the size of the string.
  output.reserve(length * 1.33);
  while (length >= 3) {
    base64Encode3to4(data, output);
    data.remove_prefix(3);
    length -= 3;
  }

  switch (length) {
  case 2:
    base64Encode2to4(data, output);
    break;
  case 1:
    base64Encode1to4(data, output);
    break;
  case 0:
    break;
  default:
    MOZ_ASSERT_UNREACHABLE("coding error");
  }
  return output;
}
std::string forgivingBase64Encode(std::string_view data) {
  int length = data.length();
  std::string output = "";
   
  output.reserve(length * 1.33);
  while (length >= 3) {
    base64Encode3to4(data, output);
    data.remove_prefix(3);
    length -= 3;
  }

  switch (length) {
  case 2:
    base64Encode2to4(data, output);
    break;
  case 1:
    base64Encode1to4(data, output);
    break;
  case 0:
    break;
  default:
    MOZ_ASSERT_UNREACHABLE("coding error");
  }
  return output;
}