• The plugin has troubles displaying UTF-8/16/unicode characters. As soon as I save a question the characters turn into wierd symbols.

    The problem lies in

    /wp-survey-and-quiz-tool/pages/admin/misc/form.php

    Delete all occurence of htmlentities(stripslashes( as these PHP functions are not UTF-8 safe.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I had the problem as same as yours, after I change Collation to utf8_unicode_ci from table and attribute (some attribute needed to change), and it work now~

    nlublovary: it is nonsense that htmlentities() wouldn’t be safe, though it may have been used incorrectly.

    Don’t remove it as it would open you up to all sorts of hacks if you do.

    Better to add the characterset as a third parameter to the function:
    htmlentities( $string, FLAGS, 'utf-8' );

    More info:
    http://nl2.php.net/manual/en/function.htmlentities.php

    Thread Starter nlublovary

    (@nlublovary)

    jrf: htmlentities() will corrupt UTF-8 data unless the author would use the appropriate flags, the proper syntax would be: htmlentities( $string, ENT_COMPAT, 'UTF-8' );

    While htmlentities() might be used to protect to a certain degree against XSS/SQL attacks, using it is bad practice. Folks recommend to use htmlspecialchars() instead, as it does the same, but doesn’t corrupt the UTF-8 data and it makes no sense to convert every character to it’s html representation, e.g. être = être. Best would be to use the built-in function: esc_html($string)

    However, htmlentities() is applied to sanitize the data while displaying (echo), but the data itself is saved into the database as-is, including html tags and possible hacks. Perhaps it would be a good idea to wrap the data while saving e.g: strip_tags($string)
    Allowing html tags e.g. in the name of a new Quizz might break the layout, try this and you’ll get a blank page after saving: <script>My Quizz

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem with unicode UTF-8’ is closed to new replies.