system — 2012-01-06T08:43:42-05:00 — #1
My database is full of user inputted data which has loads of pound symbols in it '£'. BUt they output as a strange character.
I know if I change them to £, they appear correctly but how can I do that en-masse.
So far I have tried these options
echo str_replace("£", "£", $row_rs_deals['description'])
But neither work.
Does anyone know what will convert them? Also, would it be better to convert them on the way into the databse in the future or is that impossible?
mikl — 2012-01-06T09:06:36-05:00 — #2
I don't know if this will work, but give it a try:
Instead of this:
echo str_replace("£", "£", $row_rs_deals['description']);
echo str_replace(chr(156), "£", $row_rs_deals['description']);
system — 2012-01-06T09:14:43-05:00 — #3
Close but no cigar! Still get a little square instead of the pound symbol.
Any other ideas?
mikl — 2012-01-06T09:26:34-05:00 — #4
Ah well. It was just a shot in the dark. I hope someone else will give you the answer.
raju_gautam — 2012-01-06T09:46:45-05:00 — #5
I don't know what is your character set in your page but did you try htmlentities() function something like this ?
echo htmlentities('£hello', null, 'utf-8');
logic_earth — 2012-01-06T10:00:59-05:00 — #6
You should just use UTF-8 then you can use the symbol without any conversions. ¢£¤¥
system — 2012-01-06T10:07:54-05:00 — #7
UTF 8 as the characterset for the database table?