返回列表 发帖
查看: 7221|回复: 2

后台搜索用户导出比实际少的问题

83

主题

-6

回帖

329

积分

炉火纯青

贡献
2 点
金币
241 个
发表于 2019-6-2 19:10:44 | 显示全部楼层 |阅读模式

问题现象:
     后台用户管理搜索用户然后导出,导出的用户数比实际的少
问题分析:
     Discuz! 函数中的使用的是diconv函数进行的转换,通过调试发现转换为GBK编码的时候使用iconv函数进行转换时,字符被截取了。但是 $out = iconv($in_charset, $out_charset.'//IGNORE', $str);  是带有 ‘//IGNORE ’  代表遇到转换不了的字符忽略,然而还是被截取了。最后查资料发现是iconv的bug,将iconv从‘glibc’ 更改为  ‘libiconv ’ (重新编译iconv模块)  或者,使用 mb_convert_encoding来进行转换
解决方法:
    1、 Linux环境重新编译iconv, 从‘glibc’ 更改为  ‘libiconv ’ (具体编译请到网上搜索相关资料)
    2、使用mb_convert_encoding  代替 iconv   
     打开:source/function/function_core.php
  1. function diconv($str, $in_charset, $out_charset = CHARSET, $ForceTable = FALSE) {
  2.         global $_G;

  3.         $in_charset = strtoupper($in_charset);
  4.         $out_charset = strtoupper($out_charset);

  5.         if(empty($str) || $in_charset == $out_charset) {
  6.                 return $str;
  7.         }

  8.         $out = '';

  9.         if(!$ForceTable) {
  10.                 if(function_exists('iconv')) {
  11.                         $out = iconv($in_charset, $out_charset.'//IGNORE', $str);
  12.                 } elseif(function_exists('mb_convert_encoding')) {
  13.                         $out = mb_convert_encoding($str, $out_charset, $in_charset);
  14.                 }
  15.         }

  16.         if($out == '') {
  17.                 $chinese = new Chinese($in_charset, $out_charset, true);
  18.                 $out = $chinese->Convert($str);
  19.         }

  20.         return $out;
  21. }
复制代码
更改为:
  1. function diconv($str, $in_charset, $out_charset = CHARSET, $ForceTable = FALSE) {
  2.         global $_G;

  3.         $in_charset = strtoupper($in_charset);
  4.         $out_charset = strtoupper($out_charset);

  5.         if(empty($str) || $in_charset == $out_charset) {
  6.                 return $str;
  7.         }

  8.         $out = '';

  9.         if(!$ForceTable) {
  10.                 if(function_exists('mb_convert_encoding')) {
  11.                         $out = mb_convert_encoding($str, $out_charset, $in_charset);
  12.                 }elseif(function_exists('iconv')) {
  13.                         $out = iconv($in_charset, $out_charset.'//IGNORE', $str);
  14.                 }
  15.         }

  16.         if($out == '') {
  17.                 $chinese = new Chinese($in_charset, $out_charset, true);
  18.                 $out = $chinese->Convert($str);
  19.         }

  20.         return $out;
  21. }
复制代码
提示: 使用mb_convert_encoding 函数需要开启mbstring模块



回复

使用道具 举报

14

主题

1791

回帖

2058

积分

应用开发者

discuz 老兵

贡献
8 点
金币
188 个
QQ
发表于 2019-6-2 21:00:47 | 显示全部楼层
:):)收藏啦~
回复

使用道具 举报

3

主题

118

回帖

184

积分

应用开发者

贡献
0 点
金币
58 个
发表于 2019-6-9 08:41:33 | 显示全部楼层
收藏,备用一下
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 关注公众号
  • 有偿服务微信
  • 有偿服务QQ

手机版|小黑屋|Discuz! 官方交流社区 ( 皖ICP备16010102号 |皖公网安备34010302002376号 )|网站地图|star

GMT+8, 2024-4-19 20:09 , Processed in 0.059524 second(s), 5 queries , Redis On.

Powered by Discuz! W1.0 Licensed

Cpoyright © 2001-2024 Discuz! Team.

关灯 在本版发帖
有偿服务QQ
有偿服务微信
返回顶部
快速回复 返回顶部 返回列表