10
9

More than 5 years have passed since last update.

UTF-8で作ってたら、サーバに置いてあるファイルがShift_JIS, EUC-JPだった

Last updated at Posted at 2012-10-05

Blob で読み込んで、 FileReader#readAsText を使おう!対応状況

var xhr = new XMLHttpRequest;

xhr.responseType = 'blob';
xhr.open(method, url);
xhr.onloadend = function() {
  var fr = new FileReader;
  fr.onloadend = callback.bind(fr, fr.result);
  fr.readAsText(xhr.response, encoding);
};
xhr.send(params);

iOS6, Android3.0以上だけの案件に使える。

10
9
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9