2

I am experiencing some issues with curly quotes and apostrophes when pasting from a word document into tincymce hmtl editor, for some reason it converts these characters into Â, ’ etc.

Things I have checked:

Firstly I have ensured all the html pages all have the correct content type tag declared:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Additionally, when var_dumping the output into the browser the characters display correctly which lead me into thinking that perhaps the database was not storing in UTF-8. I have checked this and when manually inserting the characters and storing them via phpMyAdmin these store perfectly fine.

So the problem seems to lie somewhere just before storing the data in the database, so to check this I enclosed the data in:

 utf8_encode(string)

Right before saving into the database and this resolves the problem. Now I don't feel this is a permanent solution but I cannot seem to figure out why this is happening.

I have tried adjusting tinyMCE encoding to 'raw':

       tinymce.init({
       entity_encoding : "raw"
    });

but this has not resolved the issue, can anyone shed some light into what might be happening here?

Michael Ramirez
  • 237
  • 5
  • 21

1 Answers1

-3

Instead of ’, you were expecting , correct? That's Mojibake, which usually implies that you failed to declare the table column to be CHARACTER SET utf8.

Do not use utf8_encode().

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • 1
    I have checked the database collations as mentioned in my original post and the table is using a utf8 character set. Your advise makes absolutely no sense considering when directly placing text into the database via phpmyadmin the text is fine, it is only when the text comes from tinyMCE that the issue presents. – Michael Ramirez Jul 15 '15 at 11:20
  • I don't know what tinyMCE is (or is not) doing that is getting in the way. One way dig deeper is to turn on MySQL's "general log", run the offending statement(s), turn off the general log, then post what is in the log. – Rick James Jul 24 '15 at 22:26
  • @MichaelRamirez - The "database" collation has no direct impact on the problem -- Instead the column's charset and the connection's charset are the important things to look at. More on Mojibake: https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Nov 29 '21 at 17:32