diff -urN program.orig/include/rcube_vcard.php program/include/rcube_vcard.php --- program.orig/include/rcube_vcard.php 2011-09-05 11:49:04.000000000 +0300 +++ program/include/rcube_vcard.php 2011-12-29 19:39:57.000000000 +0200 @@ -755,6 +755,7 @@ if ($string[0] != "\0" && $string[1] == "\0" && $string[2] != "\0" && $string[3] == "\0") return 'UTF-16LE'; // use mb_detect_encoding() +/* $encodings = array('UTF-8', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16', @@ -762,6 +763,16 @@ if (function_exists('mb_detect_encoding') && ($enc = mb_detect_encoding($string, $encodings))) return $enc; +*/ + $encodings = array('UTF-8', 'WINDOWS-1251', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', + 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', + 'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16', + 'WINDOWS-1252', 'BIG5', 'GB2312'); + + if (function_exists('mb_detect_encoding') && ($enc = mb_detect_encoding($string, $encodings))) { + if (($enc == 'ISO-8859-1') and (preg_match('/[\x80-\xFF]/', $string))) $enc = 'WINDOWS-1251'; + return $enc; + } // No match, check for UTF-8 // from http://w3.org/International/questions/qa-forms-utf-8.html