2

I need to change my character encoding to EUC-JP

Here is my code:

formData.append("send", "送信");
var xhr = new XMLHttpRequest();
xhr.open("POST", "foo.php", false);
xhr.setRequestHeader("Content-type", "text/html; charset=euc-jp");
xhr.send(formData);

I've just learned that:

Content-Type cannot be set upon sending FormData() object.

and

the default encoding is UTF-8

Because of UTF-8 encoding, I cannot receive the correct japanese characters on foo.php.

neil
  • 123
  • 9
  • Why not use UTF8 everywhere? – mplungjan Oct 03 '17 at 09:47
  • 1
    Possible duplicate of [How to force XMLHttpRequest to use ISO-8859-1 charset only?](https://stackoverflow.com/questions/11906904/how-to-force-xmlhttprequest-to-use-iso-8859-1-charset-only) – Tareq Oct 03 '17 at 09:49
  • UTF-8 should support the four groups of japanese characters, as long as it's used consistently – adeneo Oct 03 '17 at 09:50
  • @Tareq I think not? because of the sending _**FormData()**_ object part. – neil Oct 03 '17 at 09:52
  • @mplungjan my whole project is `EUC-JP`, Im using japanese characters in different forms. – neil Oct 03 '17 at 09:54
  • 1
    @neil have a look at this https://stackoverflow.com/a/22529662/5436486 – Tareq Oct 03 '17 at 10:12

0 Answers0