Support » Fixing WordPress » mysql and utf8

  • Resolved carlsandburg

    (@carlsandburg)


    I created a plugin recently, which was based on another plugin. The plugin creates a database table like this.

    $sql = “CREATE TABLE " . $wpdb->prefix . "Quotes (id MEDIUMINT(9) NOT NULL AUTO_INCREMENT PRIMARY KEY, quote TEXT NULL);”;
    dbDelta($sql);

    i got a support request that said:


    it cant work with UTF8 names and contents…
    create table like this:
    PRIMARY KEY (IDD),
    UNIQUE KEY IDD (IDD)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=1;

    first, i thought the default was utf8.

    second, i’m a bit unclear on this topic. i’ve read the details of what utf8 is, but not clear on the big picture. i guess the user wants to use the plugin using a non-English language? Can somebody explain/point out a good resource?

    thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    first, i thought the default was utf8.

    That depends on when you installed WordPress and on what server. Some older installs default to latin-1.

    So yes, you probably do want to specify the character set and collation.

    Additionally, if the server supports it, you probably want to use “utf8mb4” to get full Unicode character support. This includes 4 bytes characters that the normal utf8 will not support.

    i guess the user wants to use the plugin using a non-English language?

    Possibly. Or maybe they just want to be able to use Emoji properly. Still best to stick to utf8mb4.

    Thread Starter carlsandburg

    (@carlsandburg)

    thanks Otto, that helps.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘mysql and utf8’ is closed to new replies.