0

I want to send json data(Arabic characters) that encoded with utf8_encode of PHP:

<?php
  $output = utf8_encode('مثال');/*Arabic characters*/
  echo json_encode($output);
?>

in javascript file of page :

.
.
.
const response = JSON.parse(xhr.responseText);
const div1 = document.getElementById("div1");
div1.textContent = response ;/*show ÙØ«Ø§Ù*/
.
.
.

why response value is 'ÙØ«Ø§Ù'?

mmiinnoo
  • 3
  • 2
  • Please try with `$output = 'مثال'; echo ($output);` as php code – Wang Liang Feb 10 '20 at 03:43
  • in php I've used and only the first page of php is displayed correctly – mmiinnoo Feb 10 '20 at 03:52
  • `utf8_encode()` converts from ISO8859-1 to UTF8, and Arabic is definitvely _not_ 8859-1 [Western European codepage]. I'm willing to bet that it's already UTF8 and you should not do anything to it. – Sammitch Feb 14 '20 at 01:13

0 Answers0