I have a problem with my encoding...
Everything is UTF-8 configured, namely my database (postgres) and my php files.
when I execute this script:
$eleves = $serviceManager->getAll('Eleve');
echo "<pre>";
print_r($eleves);
echo "</pre>";
I get this:
[0] => Model_Eleve Object
(
[idEleve:Model_Eleve:private] => 28206
[numeroscolaire:Model_Eleve:private] => ABE290999JOËL
[nom:Model_Eleve:private] => Abedinpour
[prenom:Model_Eleve:private] => Joël
[dateNaissance:Model_Eleve:private] => 1999-09-29
[sexe:Model_Eleve:private] => masculin
[statusCourant:Model_Eleve:private] =>
[statusSuivant:Model_Eleve:private] =>
[adresses:Model_Eleve:private] => Array
(
[0] => Model_Adresse Object
(
[idAdresse:Model_Adresse:private] => 6176
[rue:Model_Adresse:private] => La Delèze
[numero:Model_Adresse:private] => 37
[codePostal:Model_Adresse:private] => 1164
[localite:Model_Adresse:private] => Buchillon
[emplacement:Model_Adresse:private] =>
)
)
Here everything's ok. But if I want JSON:
$eleves = $serviceManager->getAll('Eleve');
echo "<pre>";
echo json_encode($eleves, JSON_PRETTY_PRINT);
echo "</pre>";
I get this:
{
"nom": "Abedinpour",
"prenom": "Jo\u00ebl",
"adresse": [
{
"rue": "La Del\u00e8ze",
"numero": "37",
"localite": "Buchillon"
}
],
"classe": [
"7VSG\/1"
]
},
I have no idea why it works with array and doesn't work with json_encode... I've tried to transform everything in utf8 (with htmlentities) but it tells me that he can't convert 'ASCII'
When I try to show the encoding of my files with this command in the terminal:
file -I myfile.php
it returns this:
myfile.php: text/x-php; charset=us-ascii
but i can't convert it to utf8:
iconv -f us-ascii -t utf-8 myfile.php > myfile2.php
file -I myfile2.php
myfile2.php: text/x-php; charset=us-ascii
thanks in advance for your help