I want to take a string and store it in a MYSQL db. This string will be a HTML string and it can have any character encoding or be written in any language.
How can I safely save this in my MYSQL DB without affecting the HTML string so that I can later retrieve it as it is?
In addition, the field it will be stored in is of data type text and has a collation of latin1_swedish_ci will this effect it in anyway?
I am currently doing this:
htmlentities($html, ENT_QUOTES, 'UTF-8')
But I don't think the above will work for all character sets. I mean how will German or Japanese characters be affected?
Thanks for any help.
base64_encode()it before stuffing it in the DB. You won't have to use any Unicode on the DB end, just standard ASCII. (Posting this as a comment because I wouldn't call it a great answer and don't expect it to be taken as one.)