summaryrefslogtreecommitdiff
path: root/include/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/functions.php')
-rwxr-xr-xinclude/functions.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/include/functions.php b/include/functions.php
index 24c251bd3..97dbbff15 100755
--- a/include/functions.php
+++ b/include/functions.php
@@ -863,10 +863,18 @@
}
}
- // is not utf8 clean
+ function mb_substr_replace($original, $replacement, $position, $length) {
+ $startString = mb_substr($original, 0, $position, "UTF-8");
+ $endString = mb_substr($original, $position + $length, mb_strlen($original), "UTF-8");
+
+ $out = $startString . $replacement . $endString;
+
+ return $out;
+ }
+
function truncate_middle($str, $max_len, $suffix = '…') {
- if (strlen($str) > $max_len) {
- return substr_replace($str, $suffix, $max_len / 2, mb_strlen($str) - $max_len);
+ if (mb_strlen($str) > $max_len) {
+ return mb_substr_replace($str, $suffix, $max_len / 2, mb_strlen($str) - $max_len);
} else {
return $str;
}