title: your data could not be encoded because it contains invalid UTF8 characters jms/serializer-bundle symfony
body: <p>I am trying to serialize the data of -doctrine repository function- result  into JSON format, the operation faild... I am using jms/serializer-bundle... I need your help please </p>
  
  <pre><code>       $em = $this-&gt;getDoctrine()
                    -&gt;getManager();
         $repository = $em-&gt;getRepository('navormvagBundle:Stationpompage');
         $data        = $repository-&gt;find($id);
         $serializer = $this-&gt;container-&gt;get('serializer');
         $data = $serializer-&gt;serialize($data, 'json');
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/qV3JZ.png" rel="nofollow noreferrer">CRITICAL - Uncaught PHP Exception RuntimeException: "Your data could not be encoded because it contains invalid UTF8 characters." at C:\ms4w\Apache\htdocs\ormvagProject\vendor\jms\serializer\src\JMS\Serializer\JsonSerializationVisitor.php line 36 </a></p>
  
  <p>var_dump($data);
  object(nav\ormvagBundle\Entity\Communes)#358 (21) { ["objectid12":"nav\ormvagBundle\Entity\Communes":private]=> int(14) ["objectid1":"nav\ormvagBundle\Entity\Communes":private]=> int(14) ["objectid":"nav\ormvagBundle\Entity\Communes":private]=> int(461) ["codeCommu":"nav\ormvagBundle\Entity\Communes":private]=> string(13) "04.291.05.11." ["nomCommun":"nav\ormvagBundle\Entity\Communes":private]=> string(6) "OULMES" ["typeCommu":"nav\ormvagBundle\Entity\Communes":private]=> string(1) "R" ["codeProvi":"nav\ormvagBundle\Entity\Communes":private]=> string(6) "04.291" ["codeRegio":"nav\ormvagBundle\Entity\Communes":private]=> string(2) "04" ["pop2014":"nav\ormvagBundle\Entity\Communes":private]=> int(18786) ["m�nages":"nav\ormvagBundle\Entity\Communes":private]=> int(4688) ["etrangers":"nav\ormvagBundle\Entity\Communes":private]=> float(1) ["marocains":"nav\ormvagBundle\Entity\Communes":private]=> int(18785) ["nomCercle":"nav\ormvagBundle\Entity\Communes":private]=> string(6) "Oulmes" ["x":"nav\ormvagBundle\Entity\Communes":private]=> float(441447.171109) ["y":"nav\ormvagBundle\Entity\Communes":private]=> float(310925.203251) ["nomProvin":"nav\ormvagBundle\Entity\Communes":private]=> string(9) "Khemisset" ["shapeLeng":"nav\ormvagBundle\Entity\Communes":private]=> float(146137.539535) ["codeCercl":"nav\ormvagBundle\Entity\Communes":private]=> string(9) "04.291.05" ["shapeLength":"nav\ormvagBundle\Entity\Communes":private]=> float(146137.54067987) ["shapeArea":"nav\ormvagBundle\Entity\Communes":private]=> float(542883719.60999) ["wkbGeometry":"nav\ormvagBundle\Entity\Communes":private]=> string(26344) "SRID=900914;MULTIPOLYGON(((446016.130999997 319730.371199999,446125.634599999 319486.142200001,446254.220299996 319308.2588,446308.889600001 319175.070700001,446355.217600003 319163.748,446550.325000003 319184.854800001,446615.303800002 319184.508400001,446652.349200003 319173.236499999,446762.549800001 319017.605599999,446827.104000002 318961.889600001,446929.385200001 318983.4965,447125.511100002 319137.504700001 )))" }</p>