Hi all,
since years there are problems with correct conversion of special characters in the Superfecta module. At least this is the case for the Superfecta SFDatabase module when the database already uses UTF-8 as standard characterset. Nowadays almost all databases should use UTF-8 as default, I think.
There has already been a similar thread about this issue. However, it didn’t work for me:
I was able to solve this issue by making some changes in Superfecta.class.php. The problem was to find out the input encoding. See the patch below. I hope this will help others, too.
--- a/Superfecta.class.php 2021-09-07 13:10:04.548720875 +0000
+++ b/Superfecta.class.php 2021-09-07 14:50:58.138476254 +0000
@@ -207,10 +207,15 @@
if (!empty($callerid)) {
$found = true;
//$first_caller_id = _utf8_decode($first_caller_id);
- $callerid = trim(strip_tags($callerid));
- if ($superfecta->isCharSetIA5()) {
- $callerid = $superfecta->stripAccents($callerid);
+ if (function_exists('mb_detect_encoding')) {
+ if (mb_detect_encoding($callerid, ['UTF-8'], true) == 'UTF-8') {
+ $callerid = utf8_decode($callerid);
+ }
}
+ $callerid = trim(strip_tags($callerid));
+// if ($superfecta->isCharSetIA5()) {
+// $callerid = $superfecta->stripAccents($callerid);
+// }
//Why?
$callerid = preg_replace("/[\";']/", "", $callerid);
//limit caller id to the first 60 char
@@ -218,9 +223,11 @@
// Display issues on phones and CDR with special characters
// convert CNAM to UTF-8 to fix
- if (function_exists('mb_convert_encoding')) {
+ if (function_exists('mb_detect_encoding')) {
$this->out("Converting result to UTF-8");
- $callerid = mb_convert_encoding($callerid, "UTF-8");
+ $encoding = mb_detect_encoding($callerid, ['ASCII', 'CP1252', 'ISO-8859-1', 'UTF-8'], true);
+// $callerid = mb_convert_encoding($callerid, "UTF-8");
+ $callerid = iconv($encoding . '//TRANSLIT', 'UTF-8', $callerid);
}
//send off