0

From Mozilla docs:

function load_binary_resource(url) {
  var req = new XMLHttpRequest();
  req.open('GET', url, false);
  //XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com]
  req.overrideMimeType('text\/plain; charset=x-user-defined');
  req.send(null);
  if (req.status != 200) return '';
  return req.responseText;
}

The question here is, if the server is sending back data stream, what would be the encoding when the response is forced to text/plain? Is it UTF-8 or something else?

quarks
  • 33,478
  • 73
  • 290
  • 513
  • If not set in meta tag charset my best guess is utf-8. Not sure if this helps or not https://stackoverflow.com/questions/16702787/force-charset-x-user-defined-on-jquery-ajax-post – charlietfl Nov 23 '18 at 03:09
  • This should be helpful: https://xhr.spec.whatwg.org/#response-body – Randy Casburn Nov 23 '18 at 03:28

0 Answers0