utf 8 - Convert HTML entities and special characters to UTF8 text in PHP -


there lot of questions , documentation converting html entities , special characters utf8 text in php. , there php documentation itself, such htmlspecialchars_decode() , html_entity_decode(). however, not find function/solution describes how convert html characters , special entities utf-8 text. of them state "if want this, that", etc. no solution ever states "to have pure utf-8 text read humans, this".

the reason me asking, don't have test case. reading off database, , multilingual. guarantee characters in html, , need convert utf-8, in way can read humans understand languages. now, how can that? proper way sanitize/decode input pure text?

thanks.


update

here update, clear comments not asking question properly. db contains text. convert text (which contains html entities , special characters), utf-8 text can display end user on webpage. text in databae written in multiple languages (such french, arabic, english ...etc.). can contains html entities special characters. how can convert utf-8 text can read humans understand languages? remove special characters , convert them can read humans.

this works me decoding entities utf8:

html_entity_decode($str, ent_quotes | ent_html5, 'utf-8'); 

edit:-- "trick" combination in second parameter, , including encoding in third parameter. is, if did html_entity_decode($str); result not utf8.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -