关于 iconv() 函数的奇怪警告
Odd warning about iconv() function
我在 mylog 文件中收到以下警告:
PHP Warning: iconv(): Charset parameter exceeds the maximum allowed length of 64 characters in /home/jnj/PlancakeEmailParser.php on line 283
有问题的块(getBody()
函数的一部分):
if (!$detectedContentType)
{
// if here, we missed the text/plain content-type (probably it was
// in the header), thus we assume the whole body is what we are after
$body = implode("\n", $this->rawBodyLines);
}
// removing trailing new lines
$body = preg_replace('/((\r?\n)*)$/', '', $body);
if ($contentTransferEncoding == 'base64')
$body = base64_decode($body);
else if ($contentTransferEncoding == 'quoted-printable')
$body = quoted_printable_decode($body);
if($charset != 'UTF-8') {
// FORMAT=FLOWED, despite being popular in emails, it is not
// supported by iconv
$charset = str_replace("FORMAT=FLOWED", "", $charset);
$bodyCopy = $body;
$body = iconv($charset, 'UTF-8//TRANSLIT', $body);
if ($body === FALSE) { // iconv returns FALSE on failure
$body = utf8_encode($bodyCopy);
}
}
return $body;
}
我正在使用 PlancakeEmailParser.php
来解析电子邮件。我用谷歌搜索了这个错误,但没有任何结果出现在我面前。有人知道我如何或是否需要处理这个问题吗?
你说你在用PlancakeEmailParser.phpclass.
只需搜索行 :-
$bodyCopy = $body;
并更改为:-
$bodyCopy = quoted_printable_decode($body);
我在 mylog 文件中收到以下警告:
PHP Warning: iconv(): Charset parameter exceeds the maximum allowed length of 64 characters in /home/jnj/PlancakeEmailParser.php on line 283
有问题的块(getBody()
函数的一部分):
if (!$detectedContentType)
{
// if here, we missed the text/plain content-type (probably it was
// in the header), thus we assume the whole body is what we are after
$body = implode("\n", $this->rawBodyLines);
}
// removing trailing new lines
$body = preg_replace('/((\r?\n)*)$/', '', $body);
if ($contentTransferEncoding == 'base64')
$body = base64_decode($body);
else if ($contentTransferEncoding == 'quoted-printable')
$body = quoted_printable_decode($body);
if($charset != 'UTF-8') {
// FORMAT=FLOWED, despite being popular in emails, it is not
// supported by iconv
$charset = str_replace("FORMAT=FLOWED", "", $charset);
$bodyCopy = $body;
$body = iconv($charset, 'UTF-8//TRANSLIT', $body);
if ($body === FALSE) { // iconv returns FALSE on failure
$body = utf8_encode($bodyCopy);
}
}
return $body;
}
我正在使用 PlancakeEmailParser.php
来解析电子邮件。我用谷歌搜索了这个错误,但没有任何结果出现在我面前。有人知道我如何或是否需要处理这个问题吗?
你说你在用PlancakeEmailParser.phpclass.
只需搜索行 :-
$bodyCopy = $body;
并更改为:-
$bodyCopy = quoted_printable_decode($body);