mysql中的波兰语和德语重音字母

时间:2016-11-27 09:41:54

标签: mysql utf-8 collation

我想存放在独特的列抛光和德国标志中。 当我改变数据库时:

alter database osa character set utf8 collate utf8_general_ci;

我有德国标志的问题。

sql> insert into company(uuid, name) VALUE ("1","IDE")
[2016-11-27 10:37:35] 1 row affected in 13ms

sql> insert into company(uuid, name) VALUE ("2","IDĘ")
[2016-11-27 10:37:37] 1 row affected in 9ms

sql> insert into company(uuid, name) VALUE ("3","Schuring")
[2016-11-27 10:37:38] 1 row affected in 13ms

sql> insert into company(uuid, name) VALUE ("4","Schüring")
[2016-11-27 10:37:39] [23000][1062] Duplicate entry 'Schüring' for key 'UK_niu8sfil2gxywcru9ah3r4ec5'

我必须使用哪种整理?

修改

也不适用于utf8_unicode_ci

4 个答案:

答案 0 :(得分:2)

// NOTE: CODE NOT TESTED // Code from John Estropia's StackOverflow answer // https://stackoverflow.com/questions/6434377/converting-zenkaku-characters-to-hankaku-and-vice-versa-in-c-sharp public static class StringWidthHelper { private const uint LOCALE_SYSTEM_DEFAULT = 0x0800; private const uint LCMAP_HALFWIDTH = 0x00400000; private const uint LCMAP_FULLWIDTH = 0x00800000; public static string ToHalfWidth(string fullWidth) { StringBuilder sb = new StringBuilder(256); LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_HALFWIDTH, fullWidth, -1, sb, sb.Capacity); return sb.ToString(); } public static string ToFullWidth(string halfWidth) { StringBuilder sb = new StringBuilder(256); LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_FULLWIDTH, halfWidth, -1, sb, sb.Capacity); return sb.ToString(); } [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] private static extern int LCMapString(uint Locale, uint dwMapFlags, string lpSrcStr, int cchSrc, StringBuilder lpDestStr, int cchDest); } 中的_ci表示"字符不敏感"。不幸的是,这也意味着"口音不敏感"。因此,为了使COLLATIONE得到不同的对待,您需要Ę整理 - _binutf8_bin

表情符号和中文需要

utf8mb4_bin,加上一些不起眼的东西。

答案 1 :(得分:0)

将所有出现的utf8_general_ci替换为utf8_unicode_ciutf8_general_ci显然已被打破:What are the diffrences between utf8_general_ci and utf8_unicode_ci?

  

utf8_general_ci是一个非常简单的 - 在Unicode上,非常破碎 - 整理,在一般Unicode文本上提供不正确的结果。

答案 2 :(得分:0)

也许你应该尝试utf8mb4_unicode_ci?

Utf8字符集无法存储所有utf8字符。

https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html

答案 3 :(得分:0)

alter database osa character set utf8mb4 COLLATE utf8mb4_bin;

适合我。 @MaciekBryński感谢您的提示。