手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表全部文章

What's the difference between utf8_general_ci and utf8_unicode_ci

Copy from http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci

看到本文其实是源于Yii2 的migrate中的init,它其中就有一段:

PHP代码
  1. if ($this->db->driverName === 'mysql') {  
  2.     // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci  
  3.     $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';  
  4. }  

于是我才发现了上面的URL,然后打开看了下,发现是有人在提问:Between utf8_general_ci and utf8_unicode_ci, are there any differences in terms of performance?

然后有一个554个赞的评论,这样写:

There are at least two important differences:

  • Accuracy of sorting

    utf8_unicode_ci is based on the Unicode standard for sorting, and sorts accurately in a very wide range of languages.

    utf8_general_ci comes close to correct Unicode sorting in many common languages, but has a number of limitations: in some languages, it won't sort correctly at all. In others, it will merely have some quirks.

  • Performance

    utf8_general_ci is faster at comparisons and sorting, because it takes a bunch of performance-related shortcuts.

    utf8_unicode_ci uses a much more complex comparison algorithm which aims for correct sorting according in a very wide range of languages. This makes it slower to sort and compare large numbers of fields.

Unicode defines complex sets of rules for how characters should be sorted. These rules need to take into account language-specific conventions; not everybody sorts their characters in what we would call 'alphabetical order'.

  • As far as Latin (ie "European") languages go, there is not much difference between the Unicode sorting and the simplified utf8_general_ci sorting in MySQL, but there are still a few differences:

    For examples, the Unicode collation sorts "ß" like "ss", and "Œ" like "OE" as people using those characters would normally want, whereas utf8_general_ci sorts them as single characters (presumably like "s" and "e" respectively).

  • In non-latin languages, such as Asian languages or languages with different alphabets, there may be a lot more differences between Unicode sorting and the simplified utf8_general_ci sorting. The suitability of utf8_general_ci will depend heavily on the language used. For some languages, it'll be quite inadequate.

Some Unicode characters are defined as ignorable, which means they shouldn't count toward the sort order and the comparison should move on to the next character instead. utf8_unicode_ci handles these properly.

What should you use?

There is almost never any reason to use utf_general_ci anymore, as we have left behind the point where CPU speed is low enough that the performance difference would be important. Your database will almost certainly be limited by quite other bottlenecks than this nowadays. The difference in performance is only going to be measurable in extremely specialised situations, and if that's you, you'd already know about it. If you're experiencing slow sorting, in almost all cases it'll be an issue with your indexes/query plan. Changing your collation function should not be high on the list of things to troubleshoot.

When I originally wrote this answer (over 4 years ago) I said that if you wanted, you could use utf8_general_ci most of the time, and only use utf8_unicode_ci when sorting was going to be important enough to justify the performance cost. However, the performance cost is no longer really relevant (and it may not have been back then, either). It's more important to sort properly in whichever language your users are using.

One other thing I'll add is that even if you know your application only supports the English language, it may still need to deal with people's names, which can often contain characters used in other languages in which it is just as important to sort correctly. Using the Unicode rules for everything helps add peace of mind that the very smart Unicode people have worked very hard to make sorting work properly.

还有一些代码,不过我就不贴了,建议查看原网页,别说没地址。。

 

IOS下移除按钮原生样式 -webkit-appearance

如果你在ios的Safari下做过网页的预览你就会发现,它的button的效果是与你设计的完全不一样的,圆圆的效果,也不象PC上是方的,这是怎么回事?

原来,IOS环境下的按钮都是经过美化的,但通常我们在设计web app的时候不需要这些看上去老土的样式,所以,去除这些显得很有必要。

下面这句代码就是重置这些样式的:

CSS代码
  1. -webkit-appearance: none;  

因此,实际的代码就类似如下:

CSS代码
  1. input[type=button]{  
  2.     -webkit-appearance:none;  
  3.     outline:none  
  4. }  

可以试一下看看效果

又一个不错的UI皮肤

平时的工作中,除了bootstrap,其实还是有一些其他的皮肤是可以尝试的,比如这个“http://semantic-ui.com/”,你就可以看到与bootstrap等不同的效果。

semantic-ui准备了一些常用的小效果,而且自带了一些小皮肤,比如github的效果,比如bootstrap,twitter的小效果,你在使用中会发现它的好的

不多介绍,直接去官网看吧。如果你偷懒,就用这个链接下载吧:https://github.com/Semantic-Org/Semantic-UI/archive/1.10.2.zip

官网:http://semantic-ui.com/

github: https://github.com/semantic-org/semantic-ui/

Tags: semantic, bootstrap

Happy new year

羊年快乐。喜气羊羊,羊羊得意!

 
祝能看到我勃客的人在羊年里少出BUG,多出产品。皆大欢喜!
 
我自己的目标和愿望就不列出来了。也期望自己能够实现新年的愿望

yiisoft/yii2 2.0.2 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found

在composer update项目的时候,报了如标题一样的错误,当然这个错误 有一大堆

XML/HTML代码
  1. composer update  
  2. Loading composer repositories with package information  
  3. Updating dependencies (including require-dev)  
  4. Your requirements could not be resolved to an installable set of packages.  
  5.   
  6.   Problem 1  
  7.     - The requested package bower-asset/jquery could not be found in any version, there may be a typo in the package name.  
  8.   Problem 2  
  9.     - Installation request for yiisoft/yii2 dev-master -> satisfiable by yiisoft/yii2[dev-master].  
  10.     - yiisoft/yii2 dev-master requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.  
  11.   Problem 3  
  12.     - yiisoft/yii2 2.0.x-dev requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.  
  13.     - yiisoft/yii2 dev-master requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.  
  14.     - Removal request for yiisoft/yii2-imagine == 2.0.9999999.9999999-dev  
  15.     - yiisoft/yii2-imagine 2.0.0 requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].  
  16.     - yiisoft/yii2-imagine 2.0.0-rc requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].  
  17.     - yiisoft/yii2-imagine 2.0.1 requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].  
  18.     - yiisoft/yii2-imagine 2.0.2 requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].  
  19.     - Removal request for yiisoft/yii2-imagine == 9999999-dev  
  20.     - Installation request for yiisoft/yii2-imagine * -> satisfiable by yiisoft/yii2-imagine[2.0.0, 2.0.0-rc, 2.0.1, 2.0.2, 2.0.x-dev, dev-master].  
  21.   
  22. Potential causes:  
  23.  - A typo in the package name  
  24.  - The package is not available in a stable-enough version according to your minimum-stability setting  
  25.    see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.  
  26.   
  27. Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.  
看上去好纠结,但其实官方有过提示,通过查看:http://www.yiiframework.com/doc-2.0/guide-start-installation.html#installing-via-composer,可知,只要运行:
XML/HTML代码
  1. composer global require "fxp/composer-asset-plugin:1.0.0"  
问题解决。
XML/HTML代码
  1. composer update  
  2. Loading composer repositories with package information  
  3. Updating dependencies (including require-dev)  
  4. Reading bower.json of bower-asset/jquery.inputmask (3.1.47)  
  5. Could not fetch https://api.github.com/repos/RobinHerbots/jquery.inputmask/contents/bower.json?ref=9ff37e85bc2fa2350475c4a7fa60aa20cd211481, enter your GitHub credentials to go over the API rate limit  
  6. The credentials will be swapped for an OAuth token stored in /Users/*******/.composer/auth.json, your password will not be stored  
  7. To revoke access to this token you can visit https://github.com/settings/applications  
  8. Username:********  
  9. Password:********  
  10. Token successfully created  
  11. Reading bower.json of bower-asset/jquery.inputmask (3.1.44)  
  12. 。。。。。。。此处省略500字
 
 
 
 

Tags: yii2