Reputation: 1305
I have a pretty simple controller with code like this
public function deleteCarrierAction($login)
{
$settingsService = $this->get('app.settings');
$result = $settingsService->deleteCarrier($login);
if (!$result)
{
$response->setStatusCode(400, $settingsService->errorInfo);
return $response;
}
$response->setStatusCode(200);
return $response;
}
Where $settingsService->errorInfo
contains symbols in my national language. How to encode errorInfo text to UTF-8?
When I see errorInfo in Chrome browser's debug console it appears like this:
settings:251 POST http://xxxxxxx:8000/delete_carrier/79323317315 400 (Ðа кÑÑÑеÑа назнаÑÐµÐ½Ñ Ð·Ð°ÐºÐ°Ð·Ñ. Удаление невозможно)
Upvotes: 1
Views: 366
Reputation: 136
I think this is chrome issue to return info in wrong encoding.
Consider to use keys to describe info and errors, and just if u want to be more readable translate it for example in view: http://symfony.com/doc/current/best_practices/i18n.html
or in your service create method to translate error, and use it response:
$response->setStatusCode(Response::HTTP_BAD_REQUEST, $settingsService->getTranslatedErrorInfo());
Upvotes: 2