根据需要使用下面的代码试试看if (!isset($isIE)) 
    { 
        static $isIE; 
        $isIE = iif(is_browser('ie'), true, false); 
    } 
     
if ($isIE) 
    { 
        $attachmentinfo[filename] = iconv("UTF-8","GBK",$attachmentinfo[filename]);     
    } 若没有iconv库,但是Linux主机,可以将后半部分替换为:
if ($isIE) 
    { 
        $cmd = "echo '$attachmentinfo[filename]' | iconv -f UTF-8 -t GBK"; 
        $attachmentinfo[filename] = shell_exec($cmd);         
    } 其他的还没想到,不过应该可以更进一步,根据客户端编码来调整iconv的参数。
不然Big5或者日韩语系还会有问题

解决方案 »

  1.   

    不用iconv库的gb2312与utf-8的互换函数
    http://www.dev-club.com/club/bbs/showEssence.asp?id=26921
      

  2.   

    问题解决,谢谢各位,其中xuzuning(唠叨)的正则代码少了几个“\”,我重贴一下。
    <?php
    //对照表的使用
    $filename = "gb2utf8.txt";
    $fp = fopen($filename,"r");
    while(! feof($fp)) {
      list($gb,$utf8) = fgetcsv($fp,10);
      $charset[$gb] = $utf8;
    }
    fclose($fp);
    //以上读取对照表到数组备用/** gb2312到utf-8 **/
    function gb2utf8($text, &$charset) {
      //提取文本中的成分,汉字为一个元素,连续的非汉字为一个元素
      preg_match_all("/(?:[\x80-\xff].)|[\x01-\x7f]+/",$text,$tmp);
      $tmp = $tmp[0];
      //分离出汉字
      $ar = array_intersect($tmp, array_keys($charset));
      //替换汉字编码
      foreach($ar as $k=>$v)
        $tmp[$k] = $charset[$v];
      //返回换码后的串
      return join('',$tmp);
    }/** utf-8到gb2312 **/
    function utf82gb($text, &$charset) {
      $p = "/[\xf0-\xf7][\x80-\xbf]{3}|[\xe0-\xef][\x80-\xbf]{2}|[\xc2-\xdf][\x80-\xbf]|[\x01-\x7f]+/";
      preg_match_all($p,$text,$r);
      $utf8 = array_flip($charset);
      foreach($r[0] as $k=>$v)
        if(isset($utf8[$v]))
          $r[0][$k] = $utf8[$v];
      return join('',$r[0]);
    }//测试
    $s = gb2utf8('这是对照表的测试', $charset);
    echo utf82gb($s, $charset);
    ?>