I have a JTextArea from which I get the text, and send it through a POST request to a PHP page, which uses PDO and a prepare statement to insert the text into a MySQL database. This works for everything that I can type directly into the JTextArea. However, it doesn't work when I copy and paste something from Word, for example, into the JTextArea and then upload it.
For example, if I type into Word: "This is a super—long dash." Then copy and paste that in the JTextArea and have it send to the PHP page, which will upload it to the MySQL server, when I get the information back from the MySQL server (using another PHP page) it comes back as "This is a super—long dash."
This also happens for other various special characters, not just long dashes.
Is there anything I can do about this?
EDIT:
I tried to correct the issue by making sure all my php files are using utf8 to connect to mysql like so:
"mysql:host=$servername;dbname=$dbname;charset=utf8"
I also use
echo $_POST[xxx];
To make sure the text is coming in from java correctly, which it is. When I check what is the mysql database, it shows as "This is a superùlong dash". I tried to correct this by using the fixUTF8 function in the solution here: Detect encoding and make everything UTF-8 by Sebastián Grignoli. However, as a result I get "This is a super?long dash".