CI2.02发邮件长中文标题乱码
本帖最后由 smartweb 于 2011-6-17 14:32 编辑CI2.02发邮件长中文标题乱码mail.php中
$limit = 75 - 7 - strlen($this->charset);
更改为$limit = 78 - 7 - strlen($this->charset);
也是一样长中文标题乱码。
中文不能直接用php的字符串截取方法的,因為中文是2個字節,用php自帶的方法截取的話,可能漢字被截了一半,這個時候就出現亂碼了。/**
* 截取字符串
*/
if(!function_exists('mbSubstr')) {
function mbSubstr($str, $sublen)
{
if(strlen($str)<=$sublen) {
$rStr =$str;
} else {
$I = 0;
while ($I<$sublen) {
$StringTMP = substr($str,$I,1);
if (ord($StringTMP)>=224) {
$StringTMP = substr($str,$I,3);
$I = $I + 3;
} elseif (ord($StringTMP)>=192) {
$StringTMP = substr($str,$I,2);
$I = $I + 2;
} else {
$I = $I + 1;
}
$StringLast[] = $StringTMP;
}
$rStr = implode("",$StringLast);
}
return $rStr;
}
} 但我邮件内容并不是乱码。。。。。。。 smartweb 发表于 2011-6-17 12:25 static/image/common/back.gif
但我邮件内容并不是乱码。。。。。。。
這個$limit = 75 - 7 - strlen($this->charset);什麽作用的,為啥要取長度? 解决了,根本什么也不用改。
$config['charset'] = 'utf-8';
另外有我定义两个变量
// $config['newline'] = "\r\n";
//$config['crlf'] = "\r\n";
这两行注掉就正常了。 请问一下,你下面定义的那两个变量有啥作用呢?我没想明白! 定义邮件必须遵守格式,手册上有,中文的用默认的就可以了。
页:
[1]