system
January 6, 2012, 1:43pm
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’])
echo htmlspecialchars($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?
Cheers
Dave
Mikl
January 6, 2012, 2:06pm
2
I don’t know if this will work, but give it a try:
Instead of this:
echo str_replace("£", "£", $row_rs_deals['description']);
try this:
echo str_replace(chr(156), "£", $row_rs_deals['description']);
Mike
system
January 6, 2012, 2:14pm
3
Close but no cigar! Still get a little square instead of the pound symbol.
Any other ideas?
Mikl
January 6, 2012, 2:26pm
4
Ah well. It was just a shot in the dark. I hope someone else will give you the answer.
Mike
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');
You should just use UTF-8 then you can use the symbol without any conversions. ¢£¤¥
system
January 6, 2012, 3:07pm
7
UTF 8 as the characterset for the database table?