Re: Primary Key validation error on Unicode strings

From: Keith Stribley (devel@thanlwinsoft.org)
Date: Wed Nov 11 2009 - 22:24:07 CST

  • Next message: Jon Hanna: "Re: Primary Key validation error on Unicode strings"

    Wunna Ko wrote:
    > While I am working on Unicode strings with MS Database 2005, I got
    > primary key validation error when I input Burmese characters ကု "Ku"
    > while ကို "Ko" is in the database.
    >
    I would double check that you are using a Unicode character set (utf8 or
    utf16/ucs2). If the normal collation fails try a binary one.
    > The same error occurs on MySQL but with different combination.
    >
    The following script works for me in MySQL 5.1:

    set names 'utf8';
    drop database if exists testsearch;
    create database testsearch character set 'utf8';
    use testsearch;
    show variables like '%character%';
    show variables like '%collation%';
    -- the following create statements all allow the insert to occur
    create table mm (mykey varchar(128) primary key);
    -- create table mm (mykey varchar(128) primary key) collate utf8_unicode_ci;
    -- create table mm (mykey varchar(128) primary key) collate utf8_general_ci;
    -- create table mm (mykey varchar(128) primary key ) collate utf8_bin;
    show create table mm;
    insert into mm (mykey) values ('ကု'), ('ကို'), ('ကြ'), ('ကျ');
    select * from mm where mykey = 'ကု';
    select * from mm where mykey = 'ကို';
    select * from mm where mykey = 'ကျ';
    select * from mm where mykey = 'ကြ';
    select * from mm where mykey like '%ကျ%';

    In the my.cnf configuration file you can set the defaults:
    [mysqld]
    character_set_server=utf8

    [mysql]
    default_character_set=utf8

    The current version of mysql doesn't collate Myanmar correctly, but you
    can use it for storing Myanmar Unicode.

    Keith



    This archive was generated by hypermail 2.1.5 : Wed Nov 11 2009 - 22:28:54 CST