8

I send TinyMCE input to POST (a php file), then save it in MySQL Database.

The input has UTF-8 (Turkish characters). So when I type Türkçe inside the TinyMCE input and send it to post, PHP backend receives this string :

<p>T&uuml;rk&ccedil;e</p>

How can I convert it back to Türkçe so I can save it correctly in MySQL ?

P.S.:

MySQL is set to utf8_unicode_ci collation, so it can save UTF-8 characters correctly.

I need to convert them in PHP, I guess.

Or a way for TinyMCE to send them correctly?

Thanks for any help !

P.S. 2:

I think that this issue is about TinyMCE itself, so I guess the solution will be converting the TinyMCE output (either in TinyMCE javascript, or the receiving PHP script).

i.e. : I don't think changing my PHP configuration is the solution.

P.S. 3

I guess these characters like &uuml; are the HTML equivalents of Turkish characters, so htmlspecialchars_decode() should work, but it does not accept Turkish characters. Maybe a way for htmlspecialchars_decode to decode UTF-8 Characters ?

jeff
  • 13,055
  • 29
  • 78
  • 136
  • Is UTF-8 set as default charset in your php.ini ? – Kei Dec 28 '13 at 12:14
  • @Kei Maybe I can set it in my local WampServer, but I cannot modify the php.ini in my web host, so I don't know :) But other (standard) inputs can receive utf-8 text and save in the database correctly. – jeff Dec 28 '13 at 12:16
  • http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Mihai Dec 28 '13 at 12:16
  • Well, since I can't help you much more if you don't give me more details, could you run http://www.php.net/mb_detect_encoding on your $_POST['variable'] ? By this output we can understand many things – Kei Dec 28 '13 at 12:20

2 Answers2

20

Use this code

    <script type="text/javascript">
       tinymce.init({
           entity_encoding : "raw"
        });
    </script>
Amit
  • 3,251
  • 3
  • 20
  • 31
-1
tinyMCE.init
({  entities : "Ü = Ü ü = ü Ç = Ç Ç = ç Ö = Ö ö = ö",
    theme : "advanced",
    mode : "textareas",
Pang
  • 9,564
  • 146
  • 81
  • 122
shine
  • 1
  • 1
    Code only answer are discouraged. Please consider explaining what you code is doing and how it answers the question. – Matt Jul 27 '15 at 01:21