When I save "Ben and Jerry's" to my database, and later recall it from the database, into an input tag (so I can edit/resave it), I get
Ben & Jerry's
Where am I going wrong? (Notice that the "&" is correctly translated, but the apostraphe is not). Let me summarise what I am doing...
My web pages have
<meta charset="utf-8" />
and my server dispenses JSON data via PHP and
header('content-type: application/json; charset=utf-8');
My web form, using javascript/jquery, pre-post, pushes all form data thru
encodeURIComponent()
My PHP server code reads the data and pre-db-insert uses
filter_var() and FILTER_SANITIZE_STRING
My mysql db created with "utf8 - default collation" and my insert writes
Ben & Jerry's
Later.... I do a mysql select, and I thought I need only javascript call
decodeURIComponent()
to convert everything back to "Ben & Jerry's" but this appears not to be the case.
What am I missing?