aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/mb_wrapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/mb_wrapper.php')
-rw-r--r--engine/lib/mb_wrapper.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/engine/lib/mb_wrapper.php b/engine/lib/mb_wrapper.php
index 7b3327edc..411a2d5c2 100644
--- a/engine/lib/mb_wrapper.php
+++ b/engine/lib/mb_wrapper.php
@@ -42,5 +42,23 @@
return strtoupper($string);
}
+ /**
+ * Wrapper function: Returns the result of mb_substr if mb_support is present, else the
+ * result of substr is returned.
+ *
+ * @param string $string The string.
+ * @param int $start Start position.
+ * @param int $length Length.
+ * @param string $charset The charset (if multibyte support is present) : default 'UTF8'
+ * @return string
+ */
+ function elgg_substr($string, $start = 0, $length = null, $charset = 'UTF8')
+ {
+ if (is_callable('mb_substr'))
+ return mb_substr($string, $start, $length, $charset);
+
+ return substr($string, $start, $length);
+ }
+
// TODO: Other wrapper functions
?> \ No newline at end of file