Reputation: 18327
In PHP when i read the Data, let say the data (chunks of strings) is containing HTML Special Character DECIMAL HEX Codes like:
This is a sample string with œ and š
We can say above HEX codes are the source codes of its correspondence Symbol and these will be rendered as correct Symbols in Browser.
But what i want to do is, for these characters (for example), i want these HEX(es) as the converted original Character Symbols like:This is a sample string with œ and š
So how can i detect the any of decimal HEX Codes inside a string and convert each of them into final Symbol(s), instead of keeping HEX codes?
Note:
For more clearence, is there any function to detect and convert the Hex to Symbol?
Like:œ
=> œ
š
=> š
Upvotes: 3
Views: 3510
Reputation: 1927
$s = "This is a sample string with œ and š";
echo html_entity_decode($s, ENT_COMPAT, 'UTF-8');
Upvotes: 2
Reputation: 22817
Those are HTML entities - you can go back to actual symbol with html_entity_decode()
.
Upvotes: 1
Reputation: 19
make sure anything you use (database tables, json or xml for data exchange, html files etc etc etc) is in UTF-8 format
Upvotes: -1