try to fix broken UTF-8 on message display

This commit is contained in:
Klaus Leithoff 2013-07-12 09:43:22 +00:00
parent b60ee03504
commit d716c8756f
2 changed files with 26 additions and 6 deletions

View File

@ -849,9 +849,19 @@
//if (json_last_error() != JSON_ERROR_NONE && strlen($singleBodyPart['body'])>0)
if ($test=="null" && strlen($sessionData['body'])>0)
{
// this should not be needed, unless something fails with charset detection/ wrong charset passed
error_log(__METHOD__.__LINE__.' Charset problem detected; Charset Detected:'.felamimail_bo::detect_encoding($sessionData['body']));
$sessionData['body'] = utf8_encode($sessionData['body']);
// try to fix broken utf8
$x = (function_exists('mb_convert_encoding')?mb_convert_encoding($sessionData['body'],'UTF-8','UTF-8'):(function_exists('iconv')?@iconv("UTF-8","UTF-8//IGNORE",$sessionData['body']):$sessionData['body']));
$test = @json_encode($x);
if ($test=="null" && strlen($sessionData['body'])>0)
{
// this should not be needed, unless something fails with charset detection/ wrong charset passed
error_log(__METHOD__.__LINE__.' Charset problem detected; Charset Detected:'.felamimail_bo::detect_encoding($sessionData['body']));
$sessionData['body'] = utf8_encode($sessionData['body']);
}
else
{
$sessionData['body'] = $x;
}
}
}
//error_log(__METHOD__.__LINE__.$sessionData['body']);

View File

@ -1525,9 +1525,19 @@ blockquote[type=cite] {
//if (json_last_error() != JSON_ERROR_NONE && strlen($singleBodyPart['body'])>0)
if (($test=="null" || $test === false || is_null($test)) && strlen($singleBodyPart['body'])>0)
{
// this should not be needed, unless something fails with charset detection/ wrong charset passed
error_log(__METHOD__.__LINE__.' Charset Reported:'.$singleBodyPart['charSet'].' Charset Detected:'.felamimail_bo::detect_encoding($singleBodyPart['body']));
$singleBodyPart['body'] = utf8_encode($singleBodyPart['body']);
// try to fix broken utf8
$x = (function_exists('mb_convert_encoding')?mb_convert_encoding($singleBodyPart['body'],'UTF-8','UTF-8'):(function_exists('iconv')?@iconv("UTF-8","UTF-8//IGNORE",$singleBodyPart['body']):$singleBodyPart['body']));
$test = @json_encode($x);
if (($test=="null" || $test === false || is_null($test)) && strlen($singleBodyPart['body'])>0)
{
// this should not be needed, unless something fails with charset detection/ wrong charset passed
error_log(__METHOD__.__LINE__.' Charset Reported:'.$singleBodyPart['charSet'].' Charset Detected:'.felamimail_bo::detect_encoding($singleBodyPart['body']));
$singleBodyPart['body'] = utf8_encode($singleBodyPart['body']);
}
else
{
$singleBodyPart['body'] = $x;
}
}
}
//error_log($singleBodyPart['body']);