我登录到 MariaDB/MySQL 并输入:
SHOW COLLATION;
我在可用排序规则中看到 utf8mb4_unicode_ci 和 utf8mb4_unicode_520_ci。这两种归类之间有什么区别,我们应该使用哪种?
最佳答案
好吧,您可以阅读文档中的差异。我不能告诉你应该使用什么,因为每个项目都不一样。
10.1.3 Collation Naming Conventions
MySQL collation names follow these conventions:
A collation name starts with the name of the character set with which it is associated, followed by one or more suffixes indicating other collation characteristics. For example, utf8_general_ci and latin_swedish_ci are collations for the utf8 and latin1 character sets, respectively.
A language-specific collation includes a language name. For example, utf8_turkish_ci and utf8_hungarian_ci sort characters for the utf8 character set using the rules of Turkish and Hungarian, respectively.
Case sensitivity for sorting is indicated by _ci (case insensitive), _cs (case sensitive), or _bin (binary; character comparisons are based on character binary code values). For example, latin1_general_ci is case insensitive, latin1_general_cs is case sensitive, and latin1_bin uses binary code values.
For Unicode, collation names may include a version number to indicate the version of the Unicode Collation Algorithm (UCA) on which the collation is based. UCA-based collations without a version number in the name use the version-4.0.0 UCA weight keys. For example:
utf8_unicode_ci (with no version named) is based on UCA 4.0.0 weight keys >(http://www.unicode.org/Public/UCA/4.0.0/allkeys-4.0.0.txt).
utf8_unicode_520_ci is based on UCA 5.2.0 weight keys (http://www.unicode.org/Public/UCA/5.2.0/allkeys.txt).
For Unicode, the xxx_general_mysql500_ci collations preserve the pre-5.1.24 ordering of the original xxx_general_ci collations and permit upgrades for tables created before MySQL 5.1.24. For more information, see Section 2.11.3, “Checking Whether Tables or Indexes Must Be Rebuilt”, and Section 2.11.4, “Rebuilding or Repairing Tables or Indexes”.
关于mysql - MariaDB/MySQL 中 utf8mb4_unicode_ci 和 utf8mb4_unicode_520_ci 排序规则的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37307146/
在我的Rails(2.3,Ruby1.8.7)应用程序中,我需要将字符串截断到一定长度。该字符串是unicode,在控制台中运行测试时,例如'א'.length,我意识到返回了双倍长度。我想要一个与编码无关的长度,以便对unicode字符串或latin1编码字符串进行相同的截断。我已经了解了Ruby的大部分unicode资料,但仍然有些一头雾水。应该如何解决这个问题? 最佳答案 Rails有一个返回多字节字符的mb_chars方法。试试unicode_string.mb_chars.slice(0,50)
我遇到了一个非常困难的时期:#containedwithin:"MA\u008EEIKIAI"#shouldbe"MAŽEIKIAI"#natureofstring$pstring3"MA\u008EEIKIAI"$putsstring3MAEIKIAI$string3.inspect"\"MA\\u008EEIKIAI\""$string3.bytes#关于从哪里开始的任何想法?注意:这不是我的previousquestion的副本. 最佳答案 \u008E表示代码点为8e(十六进制)的unicode字符出现在字符串中的那个位置。
不幸的是,Unicode0.1(sudogeminstallunicode)不能在Ruby1.9上运行。我有以下片段:require"rubygems"require"unicode"str="áéíóúç"Unicode.normalize_KD(str).gsub(/[^\x00-\x7F]/n,"")#=>aeiouc我用它来将标题转换为永久链接,而不删除重音字符。有没有办法使用pack或unpack方法转换此类文本? 最佳答案 更新:更好的选择可能是使用gemunicode_utils这是专门为这些缺失的功能创建的:requ
我正在编写一个Rails应用程序,它需要将IDN域名从Punycode转换为它的Unicode等效项。我尝试安装idngem绑定(bind)到GNULibIDN,但它不会编译native代码。显然others与Ruby1.9.x有同样的问题。我也试过纯RubySimpleIDNgem,但我更喜欢本地的东西。 最佳答案 试试simpleidngem.它适用于Ruby1.8.7和1.9.2。编辑你的Gemfile:gem'simpleidn'然后可以输入如下命令:SimpleIDN.to_unicode("xn--mllerriis-l
我有一个包含多个组件的存储库,其中大部分是用JavaScript(Node.js)编写的,一个是用Ruby(RubyonRails)编写的。我想要一个.travis.yml文件来触发一个运行每个组件的所有测试的构建。根据thisTravisCIGoogleGroupthread,目前还没有官方支持。我的目录结构是这样的:.├──构建服务器├──核心├──扩展├──网络应用├──流浪文件├──package.json├──.travis.yml└──生成文件我希望能够运行特定版本的Ruby(2.2.2)和Node.js(0.12.2)。我已经有了一个make目标,所以maketest在每
我有以下代码#coloursarandomcellwithacorrectcolourdefcolour_random!whiletruedocol,row=rand(columns),rand(rows)cell=self[row,col]ifcell.empty?thencell.should_be_filled??cell.colour!(1):cell.colour!(0)breakendendend做什么并不重要,尽管它应该很明显。关键是Rubocop给了我一个警告Neveruse'do'withmulti-line'while为什么我不应该那样做?那我该怎么办呢?
我无法遍历整个unicode字符范围。我到处找...我正在构建一个模糊器,并希望将所有unicode字符(一次一个)嵌入到一个url中。例如:http://www.example.com?a=\uff1c我知道有一些内置工具,但我需要更多的灵active。如果我能像下面那样做:"\u"+"ff1c"那就太好了。这是我得到的最接近的:char="\u0000"...#withiniterationchar.succ!...但在字符"\u0039"之后,即数字9,我将得到"10"而不是":" 最佳答案 您可以使用pack将数字转换为UT
使用Ruby,我必须将字符串以柱状格式输出到终端。像这样:|row1|astringhere|etc|row2|anotherstring|etc我可以使用String#ljust和%s处理拉丁UTF8字符。但是当字符是韩文、中文等时就会出现问题。当英文行与包含韩文等的行交错时,列根本不会对齐。如何在此处实现列对齐?有没有办法以等同于固定宽度字体的方式输出亚洲字符?对于要在Vim中显示和编辑的文档怎么样? 最佳答案 您的问题发生在CJK(中文/日文/韩文)full-widthandwidecharacters(也向下滚动图表);这些
我正在myrapwebsite上实现全文搜索功能,我遇到了一些关于说唱歌手和歌曲名称的问题。例如,某人可能想使用查询“camron”(省略中间单词撇号)来搜索说唱歌手“Cam'ron”。同样,有人可能会使用查询“3peat”来搜索歌曲“3Peat”。“TheNotoriousB.I.G.”有点奇怪:“TheNotoriousBIG”和“TheNotoriousB.I.G.”两者都有效(我猜是因为solr.StandardFilterFactory从首字母缩略词中删除了点?),但“TheNotoriousB.I.G”(即减去结尾的点)没有。理想情况下,这些名称的所有合理变体都应该有效。我
我有这个验证规则的注册表单:validates:email,:presence=>{:message=>'cannotbeblank.'},:allow_blank=>true,:format=>{:with=>/\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/,:message=>'addressisnotvalid.Please,fixit.'},:uniqueness=>true此规则检查,如果用户填写注册表单电子邮件地址(+其正确格式)。现在我正尝试添加使用Twitter登录的机会。Twitter不提供用户的电子邮件地址。在这种情