• mysql 一些问题


    1.strlen()求的是字节长度
      _tcsclen()求的是所看到的汉字以及字母个数
      例如:strlen("你好") == 4;
        _tcsclen("你好") == 2;

    2.多字符集->unicode->utf8

     TCHAR* CTerAdd::Convert(CHAR* tmpSql)
    {
      DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, tmpSql, -1, NULL, 0);
      wchar_t *pwText;
      pwText = new wchar_t[dwNum];
     memset(pwText,0,dwNum);
      MultiByteToWideChar(CP_ACP,0,tmpSql,-1,pwText,dwNum);

      DWORD nLength   =   WideCharToMultiByte(CP_UTF8,0,pwText,-1,NULL,0,NULL,NULL);  
      TCHAR* buffer  = new TCHAR[nLength];
     memset(buffer,0,nLength);
      WideCharToMultiByte(CP_UTF8,0,pwText,-1,buffer,nLength,NULL,NULL); 

    //  //delete [] buffer;
      delete [] pwText;
      return buffer;

    }

    3.mysql administrator

     程序里转换前代码:
      insert into terminal_info(ter_sn,tel_no,sim_no,gps_no,type,comm_type,setup_date,manufacturer) values('111','222','333','444','555','666','08-12-20 17:25:16','测试')
    经过上面函数Convert()转化,返回
       insert into terminal_info(ter_sn,tel_no,sim_no,gps_no,type,comm_type,setup_date,manufacturer) values('111','222','333','444','555','666','08-12-20 17:25:16','娴嬭瘯')
    添加成功后在查看manufacturer字段为 ‘娴嬭瘯’
    如果把插入语句insert into terminal_info(ter_sn,tel_no,sim_no,gps_no,type,comm_type,setup_date,manufacturer) values('111','222','333','444','555','666','08-12-20 17:25:16','娴嬭瘯')在cmd下面执行再administrator查看为“测试”如果执行前set
    names gbk;再插入就则为'娴嬭瘯‘。


    4.错误Data too long for column 'color' at row 1
      说明再clolor字段不符合要求,比如该字符集不能够满足要插入的字符,经查看,改color字段,latin1 为utf8,OK.

  • 相关阅读:
    centos7安装webmin
    webmin账户重置密码
    gitlab访问用户安装的postgresql数据库
    更改配置:远程访问gitlab的postgresql数据库
    将gitlab中的postgresql数据库开通远程访问
    python的前后端分离(一):django+原生js实现get请求
    强制禁用gitlab的双因子认证:Two-Factor Authentication
    gitlab小结
    mysql DML语句
    基于memcache的缓存机制的6个指令
  • 原文地址:https://www.cnblogs.com/8586/p/1360777.html
Copyright © 2020-2023  润新知