1

I am having problems with Latin accent characters and php sessions. The quickest illustration is this sample code...

session_start();
$_SESSION["string_value"] = "CÉSARS";

echo($_SESSION["string_value"]);

When this executes it returns..

CÉSARS

I found I can do this and it works

session_start();
$_SESSION["string_value"] = mb_convert_encoding("CÉSARS", 'ISO-8859-1','UTF-8');
echo($_SESSION["string_value"]);

Problem is that in the actual application I am getting data from a REST service that is loading objects/data that are being used by the application and stored in session. I am hoping someone might have some way to make this all work in a seamless manner so that I can just use the objects returned by the REST service without having to run it through a conversion. Both when drawing to the screen and when using in further REST calls.

Any ideas? Searching hasn't returned much on this, was hoping it was some php.ini setting.

chris85
  • 23,846
  • 7
  • 34
  • 51
Scott Bonner
  • 2,890
  • 5
  • 27
  • 28
  • 2
    Make sure that your page is rendering using the same charset that you're receiving from this REST service.... PHP doesn't have any problems with charsets in session/browser/editor/etc as long as you're consistent – Mark Baker Sep 10 '15 at 15:23
  • It's quite possible that the issue isn't PHP, but is your server (apache, etc.) - see http://stackoverflow.com/questions/913869/how-to-change-the-default-encoding-to-utf-8-for-server – samlev Sep 10 '15 at 15:26
  • AddDefaultCharset utf-8 fixed the issue mentioned... – Scott Bonner Sep 10 '15 at 15:59

0 Answers0