So, my server was recently upgraded to PHP 5.5, and htmlspecialchars() is returning blank for some inputs. This is because PHP changed the function to expect UTF-8 encoded strings by default.
Instead of changing each and every instance of htmlspecialchars in my multiple, large websites... I was hoping instead to convert the strings BEFORE they reach this function. Namely, in the mysql database. My application is an internal MVC framework, so it loads data from the DB into an Articles class. Then the class object is used in various pages on the site like so: echo( htmlspecialchars( $article->title ) ); etc.
My mysql database is currently using MyISAM tables with an latin1_general_ci collation.
When I use PHPMyAdmin to change to collation on the Articles table to utf8_unicode_ci .... it still does not solve the problem. I can't understand why the data is not now in the proper encoding for htmlspecialchars?
Any suggestions?
(Note, I am aware of runtime solutions to rewrite the htmlspecialchars function as a work-around but this is not possible on my shared host.
I am also aware that I could search and replace across the entire site to pass in the desired encoding to every occurrence of the function, but since my site is large and several of them are encoded / go through other build process, changing this many files is a non-starter. )
Thank you!