API response breaking special characters in French |
08-15-2021, 05:31 AM
(This post was last modified: 08-16-2021, 01:02 AM by gosocial2. Edit Reason: emphasize the $message )
Hi all,
I've encountered a very odd issue after translating a CI 4.1.3 app to French in which XHR response is received with messed up characters by the browser. <?php $id = 'doesntMatter'; $message = 'L\'enregistrement de Ville a été supprimé avec succès.'; $locale = $this->request->getLocale(); log_message('debug', 'locale: ', $locale); // it is 'fr' alright ?> When using: <?php return redirect()->to(route_to('cities'))->with('success', $message); ?> Browser outputs: L'enregistrement de Ville a été supprimé avec succès. But when using it in a RESTful controller as an API reponse: <?php $reponse = $this->respondDeleted(['id' => $id], $message); log_message('debug', var_export($response, true)); return $response; ?> In the log, $message is dumped correctly, but the browser outputs: L'enregistrement de Ville a été supprimé avec succès. I'm 100% positive that all PHP files and request headers are UTF-8. (Occurred with both Chrome and Safari) This looks like a framework bug, but I will appreciate any workaround suggestions to fix it before a possible bugfix. CodeIgniter Wizard (CRUD code generator for Mac) instantly scaffolds Bootstrap-based web applications with an administrative interface (admin templates include Bootstrap5)
Try changing the nwssage string.
PHP Code: // change this Not tested, but sometimes it depends on the type of quotes. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
This is the part I have to reveal
Code: $message = lang('Basic.global.deleteSuccess'); PHP Code: $message = "L\'enregistrement de Ville a été supprimé avec succès."; did not change the result, but changing respondDeleted(...) method to the following: PHP Code: $response = $this->respondDeleted(['id' => $id, 'msg'=>$message]); and in JS Code: $.ajax({ I have yet to work out what happens with PHP Code: $this->failServerError( ... ) though. InsiteFX said: Try changing the nwssage string. PHP Code: // change this Not tested, but sometimes it depends on the type of quotes. CodeIgniter Wizard (CRUD code generator for Mac) instantly scaffolds Bootstrap-based web applications with an administrative interface (admin templates include Bootstrap5) |
Welcome Guest, Not a member yet? Register Sign In |