zoukankan      html  css  js  c++  java
  • MySQL判断中文字符的方法(转)

    准备:

    2.1、环境

    2.2、创建测试表和插入测试数据 

    方法:

    3.1、方法一:正则表达式 

    3.2、方法二:length()和char_length() 

    总结

    方法一中,[u0391-uFFE5]匹配中文以外的字符。

    方法二中,当字符集为UTF-8,并且字符为中文时,length()char_length()两个方法返回的结果不相同。

    参考官方文档:

    LENGTH()
    Return the length of a string in bytes
    Returns the length of the string str, measured in bytes. A multibyte character counts as multiple bytes. This means that for a string containing five 2-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.

    CHAR_LENGTH()
    Return number of characters in argument
    Returns the length of the string str, measured in characters. A multibyte character counts as a single character. This means that for a string containing five 2-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.

    Ref

    12.5 String Functions

    参考:

    http://blog.jobbole.com/94567/(以上内容转自此篇文章)

  • 相关阅读:
    git爬坑不完全指北(二):failed to push some refs to ‘XXX’的解决方案
    javascript精雕细琢(三):作用域与作用域链
    javascript精雕细琢(二):++、--那点事
    git爬坑不完全指北(一):Permission to xxx.git denied to user的解决方案
    深入浅出CSS(三):隐藏BOSS大盘点之默认属性小总结
    读书笔记
    MPP5运维手册
    HTML自闭合(self-closing)标签
    Mysql JDBC的通信协议(报文的格式和基本类型)
    详解 & 0xff 的作用
  • 原文地址:https://www.cnblogs.com/EasonJim/p/8084441.html
Copyright © 2011-2022 走看看