0

I use

"name": "friendsofsymfony/rest-bundle",
"version": "1.7.7",

"name": "jms/serializer-bundle",
"version": "0.13.0"

When my response contains a word in Cyrilic, I the response like this:

return View::create()
->setStatusCode(200)
->setData($response)
->setSerializationContext(
    SerializationContext::create()
        ->setGroups(array('my_group'))
);

I get an error:

{
    "message": "Your data could not be encoded because it contains invalid UTF8 characters.",
    "class": "RuntimeException",
    "trace": [
      {
        "namespace": "",
        "short_class": "",
        "class": "",
        "type": "",
        "function": "",
        "file": "/home/ivan/host/aog-code/vendor/jms/serializer/src/JMS/Serializer/JsonSerializationVisitor.php",
        "line": 36,
        "args": []
      },

$response is array, but I find problem I have bad symbhol after $rest = substr("abcdef", -1); when I using $shortName = $entity->getFirstName() . ($last ? ' ' . ' ' . preg_replace("/^([a-zа-я]).*$/isu", "$1", trim($last)) . '.' : ''); have norm sumbhol and have response without error I can not understand why this happens.

Cœur
  • 37,241
  • 25
  • 195
  • 267
shuba.ivan
  • 3,824
  • 8
  • 49
  • 121
  • are you using doctrine, is your `$response` variable a string or an object? – takeit Aug 12 '16 at 08:41
  • `$response` is array, but I find problem I have bad symbhol after `$rest = substr("abcdef", -1);` when I using `$shortName = $entity->getFirstName() . ($last ? ' ' . ' ' . preg_replace("/^([a-zа-я]).*$/isu", "$1", trim($last)) . '.' : '');` have norm sumbhol and have response without error – shuba.ivan Aug 22 '16 at 07:08

0 Answers0