Symfony\Component\HttpFoundation\Response::setCharset PHP Method

setCharset() public method

Sets the response charset.
public setCharset ( string $charset ) : Response
$charset string Character set
return Response
    public function setCharset($charset)
    {
        $this->charset = $charset;

        return $this;
    }

Usage Example

Example #1
0
 protected function sendResponse($payload = NULL)
 {
     $this->res->setExpiration(FALSE);
     if (is_null($payload)) {
         $this->res->setStatusCode(204);
     } else {
         $this->res->setCharset('utf8');
         $this->res->headers->set('Content-Type', 'application/json');
         $content = json_encode($payload, JSON_PRETTY_PRINT);
         $this->res->setContent($content);
     }
     $this->res->send();
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Response::setCharset