aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/lib/StringUtil.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-10-11 18:41:34 +0000
committerMario <mario@mariovavti.com>2022-10-11 18:41:34 +0000
commit10ba98c4f5ec4efe6272516de47f0ce128ef2902 (patch)
treefbbde69114acba764cf6b735433c53e099fd19c5 /vendor/sabre/vobject/lib/StringUtil.php
parent108a3efe0b6d37a7ed394a84c69b924ca727f17a (diff)
downloadvolse-hubzilla-10ba98c4f5ec4efe6272516de47f0ce128ef2902.tar.gz
volse-hubzilla-10ba98c4f5ec4efe6272516de47f0ce128ef2902.tar.bz2
volse-hubzilla-10ba98c4f5ec4efe6272516de47f0ce128ef2902.zip
Revert "update composer libs"
This reverts commit 108a3efe0b6d37a7ed394a84c69b924ca727f17a.
Diffstat (limited to 'vendor/sabre/vobject/lib/StringUtil.php')
-rw-r--r--vendor/sabre/vobject/lib/StringUtil.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/vendor/sabre/vobject/lib/StringUtil.php b/vendor/sabre/vobject/lib/StringUtil.php
index b04539e4a..2333d6ab9 100644
--- a/vendor/sabre/vobject/lib/StringUtil.php
+++ b/vendor/sabre/vobject/lib/StringUtil.php
@@ -40,11 +40,23 @@ class StringUtil
*/
public static function convertToUTF8($str)
{
- if (!mb_check_encoding($str, 'UTF-8') && mb_check_encoding($str, 'ISO-8859-1')) {
- $str = mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1');
+ $encoding = mb_detect_encoding($str, ['UTF-8', 'ISO-8859-1', 'WINDOWS-1252'], true);
+
+ switch ($encoding) {
+ case 'ISO-8859-1':
+ $newStr = utf8_encode($str);
+ break;
+ /* Unreachable code. Not sure yet how we can improve this
+ * situation.
+ case 'WINDOWS-1252' :
+ $newStr = iconv('cp1252', 'UTF-8', $str);
+ break;
+ */
+ default:
+ $newStr = $str;
}
// Removing any control characters
- return preg_replace('%(?:[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', '', $str);
+ return preg_replace('%(?:[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', '', $newStr);
}
}