AlexanderR
asked on
html_entity_decode returns different results in linux from windows
When i am in windows html_entity_decode seems to work fine. It propperly replaces with a space. When i apply the same code in linux, it returns a weird white question mark within a black square (rombus).
It seems to do other characters propperly, like < to <, but why it cant do ?. Of course i can do str_replace(" ", " ", $mystring), but that dont look right.
Can someone please explain?
PHP 5.2.1 Kubuntu.
It seems to do other characters propperly, like < to <, but why it cant do ?. Of course i can do str_replace(" ", " ", $mystring), but that dont look right.
Can someone please explain?
PHP 5.2.1 Kubuntu.
ASKER
Thanks, but it didnt.
Its not just a problem of browser output. (that would be easy, just change the display coding, like you said). However problem goes way deeper.
I have other functions down the line, that split the resulting string into multiple strings based on a space, then each of those are used as either SELECT or INSERT (depends on what stage of the application you are at) for appropriate columns in the DB. Of course all of that fails because of that one character, so explode(" ", $afterhtmldecode) doesnt work.
You could as why dont i do explode(" "$string), but what if at some point the space is an actual space rather than  .
Its not just a problem of browser output. (that would be easy, just change the display coding, like you said). However problem goes way deeper.
I have other functions down the line, that split the resulting string into multiple strings based on a space, then each of those are used as either SELECT or INSERT (depends on what stage of the application you are at) for appropriate columns in the DB. Of course all of that fails because of that one character, so explode(" ", $afterhtmldecode) doesnt work.
You could as why dont i do explode(" "$string), but what if at some point the space is an actual space rather than  .
Does it work if you specify a locale:
setlocale(LC_ALL, 'en_GB.UTF-8');
Just a long shot. I'm having trouble getting PHP to work with that locale myself.
setlocale(LC_ALL, 'en_GB.UTF-8');
Just a long shot. I'm having trouble getting PHP to work with that locale myself.
(Ah, you can check which locales are installed in Ubuntu by typing "locales -a" in the terminal.)
(Sorry, there's no s, it's just "locale -a".)
ASKER
setlocale didnt work. I even tried some other locales like en_US, but all same.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. I hope B is satisfactory grade, as i did not get a true solution or explanation, but only a workaround.
my guess is php is printing in, lets say, UTF8 and your HTML header states (or may not even be included) to display characters using ISO 8859-1 Latin 1, for example
try this line in your HTML, it may fix the problem
<meta http-equiv="content-type" content="text/html; charset=UTF-8">