Can i omit non-unicode characters to avoid the error: Server Error! (OK). The sent-mail folder from another webmail are with non-unicode characters. How can omit these characters?
Tiago Gomes wrote:
Can i omit non-unicode characters to avoid the error: Server Error! (OK). The sent-mail folder from another webmail are with non-unicode characters. How can omit these characters?
Supplement: this happens in IE8 when rcmail_js_message_list() returns data with non-unicode characters.
I got function to remove those characters. It fixes the issue, but I'm not sure if this is one and only solution.
function rc_utf8_clean($str) { // iconv is 10x faster if (function_exists('iconv')) return iconv('UTF8', 'UTF8//IGNORE', $str);
$regexp = '/^('.
// '[\x00-\x7F]'. // UTF8-1 '|[\xC2-\xDF][\x80-\xBF]'. // UTF8-2 '|\xE0[\xA0-\xBF][\x80-\xBF]'. // UTF8-3 '|[\xE1-\xEC][\x80-\xBF][\x80-\xBF]'. // UTF8-3 '|\xED[\x80-\x9F][\x80-\xBF]'. // UTF8-3 '|[\xEE-\xEF][\x80-\xBF][\x80-\xBF]'. // UTF8-3 '|\xF0[\x90-\xBF][\x80-\xBF][\x80-\xBF]'. // UTF8-4 '|[\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF]'.// UTF8-4 '|\xF4[\x80-\x8F][\x80-\xBF][\x80-\xBF]'. // UTF8-4 ')$/'; $seq = ''; $out = '';
for ($i = 0, $len = strlen($str)-1; $i < $len; $i++) {
$chr = $str[$i];
$ord = ord($chr);
// 1-byte character
if ($ord <= 0x7F) {
if ($seq)
$out .= preg_match($regexp, $seq) ? $seq : '';
$seq = '';
$out .= $chr;
// first (or second) byte of multibyte sequence
} else if ($ord >= 0xC0) {
if (strlen($seq)>1) {
$out .= preg_match($regexp, $seq) ? $seq : '';
$seq = '';
} else if ($seq && ord($seq) < 0xC0) {
$seq = '';
}
$seq .= $chr;
// next byte of multibyte sequence
} else if ($seq) {
$seq .= $chr;
}
}
if ($seq)
$out .= preg_match($regexp, $seq) ? $seq : '';
return $out;
}
On Wed, Jul 22, 2009 at 14:16, Tiago Gomesalgodas@gmail.com wrote:
Can i omit non-unicode characters to avoid the error: Server Error! (OK). The sent-mail folder from another webmail are with non-unicode characters. How can omit these characters?
Hi, can you send us a sample message that causes theses problems? I'd like to reproduce and test it in order to find a solution. The rc_utf8_clean() funtion will probably solve the problem but it also could have side-effects.
Regards, Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/
Thomas Bruederli wrote:
Hi, can you send us a sample message that causes theses problems? I'd like to reproduce and test it in order to find a solution. The rc_utf8_clean() funtion will probably solve the problem but it also could have side-effects.
I've got one. Attached.
related to the problem that causes Server Error! (OK) due to non-unicode encoding , i'm fix change in program/include/rcube_imap.php line 2669, where I force an encoding when unknown ( ="0" ) , I don't arealdy problem about this. Thank's
/* return rcube_charset_convert($rest, $a[0]); } else return $str; // we dont' know what to do with this } */* *if ( $a[0] == "0"){return rcube_charset_convert($rest, 'iso-8859-1'); } else if ( $a[0] <> "0" ) { return rcube_charset_convert($rest, $a[0]); }*
}
else
return $str; // we dont' know what to do with this
}
2009/7/31 A.L.E.C alec@alec.pl
Thomas Bruederli wrote:
Hi, can you send us a sample message that causes theses problems? I'd
like to reproduce and test it in order to find a solution. The rc_utf8_clean() funtion will probably solve the problem but it also could have side-effects.
I've got one. Attached.
-- Aleksander 'A.L.E.C' Machniak http://alec.pl gg:2275252 LAN Management System Developer http://lms.org.pl Roundcube Webmail Project Developer http://roundcube.net
--- 8< --- detachments --- 8< --- The following attachments have been detached and are available for viewing. http://detached.gigo.com/rc/XM/3Q7mhN1i/test.msg Only click these links if you trust the sender, as well as this message. --- 8< --- detachments --- 8< ---
List info: http://lists.roundcube.net/dev/