• Resolved firebird75

    (@firebird75)


    Hello,
    There is a little bug with the custom text you can enter in the options. This is the custom texts to be displayed next to the stars. If you enter special characters like à or é, these won’t be saved properly due to an encoding issue in the code. You can easily reproduce the issue by entering an à in the text, save the option and then see that the à is encoded to something else due to this encoding issue.
    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor dudo

    (@dudo)

    Hi,

    This is pretty strange because that string are store in a default WordpPress table.

    I made a test (Screenshoot here https://ibb.co/r6QdVn7 ) and everything is fine indeed.

    Are you sure your database is in UTF-8?

    Thread Starter firebird75

    (@firebird75)

    I have checked and found out that the table had been created as with latin1_swedish_ci encoding. So I have checked the plugin code and it looks like you aren’t explicitly setting the character encoding to be used. This is what is causing the issue to happen. The right way to create the table is to check user DB charset and then to explicitly force it for new tables. Otherwise, it will switch down to random values and eventually cause problems.

    Here is a code snippet to help you :

    
    	if ($wpdb->has_cap('collation')) 
    	{
    		if (!empty($wpdb->charset))
    			$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    		if (!empty($wpdb->collate))
                $charset_collate .= " COLLATE $wpdb->collate";
    	}
    
    $wpdb->query("CREATE TABLE IF NOT EXISTS {$wpdb->prefix}mytable (
    	  id int(11) unsigned NOT NULL auto_increment,
    	  optionvalue text,
    	  PRIMARY KEY  (id)
    	) $charset_collate;");
    

    The query part is missing quotes (those get stripped off in this editor).

    To fix the issue for existing installs, you will need to alter the DB encoding for your plugin tables. This should correct the issue.

    • This reply was modified 5 years, 6 months ago by firebird75.
    • This reply was modified 5 years, 6 months ago by firebird75.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Encoding issue’ is closed to new replies.