问题现象:
      后台用户管理搜索用户然后导出,导出的用户数比实际的少
问题分析:
     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 模块