summaryrefslogtreecommitdiff
path: root/includes/unicode.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/unicode.inc')
-rw-r--r--includes/unicode.inc4
1 files changed, 3 insertions, 1 deletions
diff --git a/includes/unicode.inc b/includes/unicode.inc
index f25f472d2..8c2f64970 100644
--- a/includes/unicode.inc
+++ b/includes/unicode.inc
@@ -207,7 +207,9 @@ function drupal_truncate_bytes($string, $len) {
if ((ord($string[$len]) < 0x80) || (ord($string[$len]) >= 0xC0)) {
return substr($string, 0, $len);
}
- while (--$len >= 0 && ord($string[$len]) >= 0x80 && ord($string[$len]) < 0xC0) {};
+ // Scan backwards to beginning of the byte sequence.
+ while (--$len >= 0 && ord($string[$len]) >= 0x80 && ord($string[$len]) < 0xC0);
+
return substr($string, 0, $len);
}