Just like LENGTH() function, MySQL BIT_LENGTH() function is not a multi-byte safe function. As we know that the difference of the result between multi-byte safe functions, like CHAR_LENGTH() or CHARACTER_LENGTH(), and BIT_LENGTH() function especially relevant for Unicode, in which most of the characters are encoded in two bytes or relevant for UTF-8 where the number of bytes varies. It is demonstrated in the example below −
Example
mysql> Select BIT_LENGTH('tutorialspoint');
+------------------------------+
| BIT_LENGTH('tutorialspoint') |
+------------------------------+
| 112 |
+------------------------------+
1 row in set (0.00 sec)The above result set shows that the bit length of string ‘tutorialspoint’ is 112 because it is yet not converted to Unicode character. The following query converts it into Unicode character −
mysql> SET @A = CONVERT('tut
orialspoint' USING ucs2);
Query OK, 0 rows affected (0.02 sec)在将字符串转换为Unicode后,结果为224而不是112,因为在Unicode中,一个字符占用2个字节,如下所示 −
mysql> Select BIT_LENGTH(@A); +----------------+ | BIT_LENGTH(@A) | +----------------+ | 224 | +----------------+ 1 row in set (0.00 sec)
文章推荐更多>
- 1mysql属于哪种数据库类型
- 2wordpress怎么做固定链接
- 3手机夸克怎么退出登录 手机端退出登录教程
- 4wordpress怎么实现实时刷新
- 5phpmyadmin导出功能可以导出什么
- 6夸克怎么免费解压zip zip格式解压方法
- 7WordPress怎么清除用户缓存
- 8mongodb怎么修改数据
- 9oracle数据备份怎么操作
- 10oracle怎么设置定时任务
- 11Wordpress怎么关闭文章时间
- 12电脑截图的6种方法 六种实用截图技巧分享
- 13mysql数据库属于哪种结构模型
- 14uc浏览器官网网页版入口 uc浏览器官网网页进入地址
- 15redis怎么读写分离
- 16mysql属于什么类型的数据库?
- 17mysql怎么恢复修改的数据
- 18redis 和 mysql 的数据不一致怎么办
- 19电脑键盘打不了字是什么原因 键盘失灵原因分析及解决方案汇总
- 20oracle数据库怎么备份表结构
- 21mysql怎么使用表
- 22phpmyadmin怎么取消主键
- 23wordpress中如何更改上传图片的大小
- 24夸克怎么免费解压zip压缩文件 zip文件解压教程
- 25oracle数据库怎么备份数据
- 26怎么安装帝国cms
- 27phpmyadmin访问不了怎么回事
- 28电脑开机了但是一直转圈圈 开机转圈卡死解决方法加速系统启动
- 29redis是做什么的
- 30怎么更换wordpress主题logo

orialspoint' USING ucs2);
Query OK, 0 rows affected (0.02 sec)