Title: Encoding issue
Last modified: August 26, 2019

---

# Encoding issue

 *  Resolved [firebird75](https://wordpress.org/support/users/firebird75/)
 * (@firebird75)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/encoding-issue-7/)
 * 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](https://wordpress.org/support/users/dudo/)
 * (@dudo)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/encoding-issue-7/#post-11867821)
 * 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](https://ibb.co/r6QdVn7))
   and everything is fine indeed.
 * Are you sure your database is in UTF-8?
 *  Thread Starter [firebird75](https://wordpress.org/support/users/firebird75/)
 * (@firebird75)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/encoding-issue-7/#post-11867917)
 * 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 6 years, 9 months ago by [firebird75](https://wordpress.org/support/users/firebird75/).
    -  This reply was modified 6 years, 9 months ago by [firebird75](https://wordpress.org/support/users/firebird75/).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Encoding issue’ is closed to new replies.

 * ![](https://ps.w.org/yet-another-stars-rating/assets/icon-256x256.png?rev=1525329)
 * [YASR - Yet Another Star Rating Plugin for WordPress](https://wordpress.org/plugins/yet-another-stars-rating/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yet-another-stars-rating/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yet-another-stars-rating/)
 * [Active Topics](https://wordpress.org/support/plugin/yet-another-stars-rating/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yet-another-stars-rating/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yet-another-stars-rating/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [firebird75](https://wordpress.org/support/users/firebird75/)
 * Last activity: [6 years, 9 months ago](https://wordpress.org/support/topic/encoding-issue-7/#post-11867917)
 * Status: resolved