summaryrefslogtreecommitdiff
path: root/includes/common.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-11-21 20:17:44 +0000
committerDries Buytaert <dries@buytaert.net>2004-11-21 20:17:44 +0000
commitb442fad027a7446aaa46068ecf180bc2c35b683c (patch)
tree0a2625ae4c334c7a341b3a8e320c9bbd4d800966 /includes/common.inc
parent5f29fc9d0d4def8de7aeaef0af715320e74d1279 (diff)
downloadbrdo-b442fad027a7446aaa46068ecf180bc2c35b683c.tar.gz
brdo-b442fad027a7446aaa46068ecf180bc2c35b683c.tar.bz2
- Patch #13263 and #13265 by arnab: added word-based truncation and made the comment module use it to extract subjects.
Diffstat (limited to 'includes/common.inc')
-rw-r--r--includes/common.inc7
1 files changed, 6 insertions, 1 deletions
diff --git a/includes/common.inc b/includes/common.inc
index dc72c88b9..31f3f426d 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1722,14 +1722,19 @@ function drupal_xml_parser_create(&$data) {
* The string to truncate.
* @param $len
* An upper limit on the returned string length.
+ * @param $wordsafe
+ * Flag to truncate at nearest word boundary. Defaults to FALSE.
* @return
* The truncated string.
*/
-function truncate_utf8($string, $len) {
+function truncate_utf8($string, $len, $wordsafe = FALSE) {
$slen = strlen($string);
if ($slen <= $len) {
return $string;
}
+ if ($wordsafe) {
+ while (($string[--$len] != ' ') && ($len > 0)) {};
+ }
if ((ord($string[$len]) < 0x80) || (ord($string[$len]) >= 0xC0)) {
return substr($string, 0, $len);
}