Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.175
diff -u -p -r1.175 locale.inc
--- includes/locale.inc	14 Apr 2008 17:48:33 -0000	1.175
+++ includes/locale.inc	23 Apr 2008 09:39:59 -0000
@@ -1979,7 +1979,7 @@ function _locale_translate_seek() {
     foreach ($arr as $lid => $value) {
       $rows[] = array(
         $value['group'],
-        array('data' => check_plain(truncate_utf8($value['source'], 150, FALSE, TRUE)) . '<br /><small>' . $value['location'] . '</small>'),
+        array('data' => check_plain(drupal_truncate_chars($value['source'], 150, FALSE, TRUE)) . '<br /><small>' . $value['location'] . '</small>'),
         array('data' => _locale_translate_language_list($value['languages'], $limit_language), 'align' => 'center'),
         array('data' => l(t('edit'), "admin/build/translate/edit/$lid"), 'class' => 'nowrap'),
         array('data' => l(t('delete'), "admin/build/translate/delete/$lid"), 'class' => 'nowrap'),
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.420
diff -u -p -r1.420 theme.inc
--- includes/theme.inc	14 Apr 2008 17:48:33 -0000	1.420
+++ includes/theme.inc	23 Apr 2008 09:39:59 -0000
@@ -1544,12 +1544,7 @@ function theme_username($object) {
 
   if ($object->uid && $object->name) {
     // Shorten the name when it is too long or it will break many tables.
-    if (drupal_strlen($object->name) > 20) {
-      $name = drupal_substr($object->name, 0, 15) . '...';
-    }
-    else {
-      $name = $object->name;
-    }
+    $name = drupal_truncate_chars($object->name, 20, FALSE, TRUE);
 
     if (user_access('access user profiles')) {
       $output = l($name, 'user/' . $object->uid, array('title' => t('View user profile.')));
Index: includes/unicode.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/unicode.inc,v
retrieving revision 1.30
diff -u -p -r1.30 unicode.inc
--- includes/unicode.inc	14 Apr 2008 17:48:33 -0000	1.30
+++ includes/unicode.inc	23 Apr 2008 09:39:59 -0000
@@ -196,8 +196,8 @@ function drupal_convert_to_utf8($data, $
  *
  * Use this function whenever you want to chop off a string at an unsure
  * location. On the other hand, if you're sure that you're splitting on a
- * character boundary (e.g. after using strpos() or similar), you can safely use
- * substr() instead.
+ * character boundary (e.g. after using drupal_strlen() or similar), you can
+ * safely use drupal_truncate_chars() instead.
  *
  * @param $string
  *   The string to truncate.
@@ -231,17 +231,17 @@ function drupal_truncate_bytes($string, 
  * @return
  *   The truncated string.
  */
-function truncate_utf8($string, $len, $wordsafe = FALSE, $dots = FALSE) {
+function drupal_truncate_chars($string, $len, $wordsafe = FALSE, $dots = FALSE) {
 
   if (drupal_strlen($string) <= $len) {
     return $string;
   }
 
-  if ($dots) {
-    $len -= 4;
-  }
-
   if ($wordsafe) {
+    if ($dots) {
+      // Make room for ' ...' if needed.
+      $len -= 4;
+    }
     $string = drupal_substr($string, 0, $len + 1); // leave one more character
     if ($last_space = strrpos($string, ' ')) { // space exists AND is not on position 0
       $string = substr($string, 0, $last_space);
@@ -249,15 +249,18 @@ function truncate_utf8($string, $len, $w
     else {
       $string = drupal_substr($string, 0, $len);
     }
+    if ($dots) {
+      $string .= ' ...';
+    }
+  }
+  elseif ($dots) {
+    $len -= 3; // Make room for '...'
+    $string = drupal_substr($string, 0, $len) . '...';
   }
   else {
     $string = drupal_substr($string, 0, $len);
   }
 
-  if ($dots) {
-    $string .= ' ...';
-  }
-
   return $string;
 }
 
@@ -271,8 +274,8 @@ function truncate_utf8($string, $len, $w
  *
  * Notes:
  * - Only encode strings that contain non-ASCII characters.
- * - We progressively cut-off a chunk with truncate_utf8(). This is to ensure
- *   each chunk starts and ends on a character boundary.
+ * - We progressively cut-off a chunk with truncate_truncate_bytes(). This is to
+ *   ensure each chunk starts and ends on a byte boundary.
  * - Using \n as the chunk separator may cause problems on some systems and may
  *   have to be changed to \r\n or \r.
  */
Index: modules/aggregator/aggregator.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v
retrieving revision 1.377
diff -u -p -r1.377 aggregator.module
--- modules/aggregator/aggregator.module	14 Apr 2008 17:48:34 -0000	1.377
+++ modules/aggregator/aggregator.module	23 Apr 2008 09:39:59 -0000
@@ -740,7 +740,7 @@ function aggregator_parse_feed(&$data, $
       $title = $item['TITLE'];
     }
     elseif (!empty($item['DESCRIPTION'])) {
-      $title = preg_replace('/^(.*)[^\w;&].*?$/', "\\1", truncate_utf8($item['DESCRIPTION'], 40));
+      $title = preg_replace('/^(.*)[^\w;&].*?$/', "\\1", drupal_truncate_chars($item['DESCRIPTION'], 40));
     }
     else {
       $title = '';
Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.460
diff -u -p -r1.460 book.module
--- modules/book/book.module	14 Apr 2008 17:48:35 -0000	1.460
+++ modules/book/book.module	23 Apr 2008 09:40:00 -0000
@@ -844,7 +844,7 @@ function _book_toc_recurse($tree, $inden
       break;
     }
     if (!in_array($data['link']['mlid'], $exclude)) {
-      $toc[$data['link']['mlid']] = $indent . ' ' . truncate_utf8($data['link']['title'], 30, TRUE, TRUE);
+      $toc[$data['link']['mlid']] = $indent . ' ' . drupal_truncate_chars($data['link']['title'], 30, TRUE, TRUE);
       if ($data['below']) {
         _book_toc_recurse($data['below'], $indent . '--', $toc, $exclude, $depth_limit);
       }
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.627
diff -u -p -r1.627 comment.module
--- modules/comment/comment.module	16 Apr 2008 11:26:28 -0000	1.627
+++ modules/comment/comment.module	23 Apr 2008 09:40:00 -0000
@@ -1499,7 +1499,7 @@ function _comment_form_submit(&$comment_
     // 2) Strip out all HTML tags
     // 3) Convert entities back to plain-text.
     // Note: format is checked by check_markup().
-    $comment_values['subject'] = trim(truncate_utf8(decode_entities(strip_tags(check_markup($comment_values['comment'], $comment_values['format']))), 29, TRUE));
+    $comment_values['subject'] = trim(drupal_truncate_chars(decode_entities(strip_tags(check_markup($comment_values['comment'], $comment_values['format']))), 29, TRUE));
     // Edge cases where the comment body is populated only by HTML tags will
     // require a default subject.
     if ($comment_values['subject'] == '') {
Index: modules/dblog/dblog.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/dblog/dblog.admin.inc,v
retrieving revision 1.7
diff -u -p -r1.7 dblog.admin.inc
--- modules/dblog/dblog.admin.inc	14 Apr 2008 17:48:36 -0000	1.7
+++ modules/dblog/dblog.admin.inc	23 Apr 2008 09:40:00 -0000
@@ -68,7 +68,7 @@ function dblog_overview() {
         $icons[$dblog->severity],
         t($dblog->type),
         format_date($dblog->timestamp, 'small'),
-        l(truncate_utf8(_dblog_format_message($dblog), 56, TRUE, TRUE), 'admin/reports/event/' . $dblog->wid, array('html' => TRUE)),
+        l(drupal_truncate_chars(_dblog_format_message($dblog), 56, TRUE, TRUE), 'admin/reports/event/' . $dblog->wid, array('html' => TRUE)),
         theme('username', $dblog),
         $dblog->link,
       ),
@@ -102,7 +102,7 @@ function dblog_top($type) {
 
   $rows = array();
   while ($dblog = db_fetch_object($result)) {
-    $rows[] = array($dblog->count, truncate_utf8(_dblog_format_message($dblog), 56, TRUE, TRUE));
+    $rows[] = array($dblog->count, drupal_truncate_chars(_dblog_format_message($dblog), 56, TRUE, TRUE));
   }
 
   if (empty($rows)) {
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.209
diff -u -p -r1.209 filter.module
--- modules/filter/filter.module	14 Apr 2008 17:48:37 -0000	1.209
+++ modules/filter/filter.module	23 Apr 2008 09:40:00 -0000
@@ -844,12 +844,7 @@ function _filter_url_trim($text, $length
     $_length = $length;
   }
 
-  // Use +3 for '...' string length.
-  if (strlen($text) > $_length + 3) {
-    $text = substr($text, 0, $_length) . '...';
-  }
-
-  return $text;
+  return drupal_truncate_chars($text, $_length, FALSE, TRUE);
 }
 
 /**
Index: modules/menu/menu.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v
retrieving revision 1.161
diff -u -p -r1.161 menu.module
--- modules/menu/menu.module	14 Apr 2008 17:48:37 -0000	1.161
+++ modules/menu/menu.module	23 Apr 2008 09:40:00 -0000
@@ -232,7 +232,7 @@ function _menu_parents_recurse($tree, $m
       break;
     }
     if ($data['link']['mlid'] != $exclude && $data['link']['hidden'] >= 0) {
-      $title = $indent . ' ' . truncate_utf8($data['link']['title'], 30, TRUE, FALSE);
+      $title = $indent . ' ' . drupal_truncate_chars($data['link']['title'], 30, TRUE, FALSE);
       if ($data['link']['hidden']) {
         $title .= ' (' . t('disabled') . ')';
       }
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.958
diff -u -p -r1.958 node.module
--- modules/node/node.module	20 Apr 2008 05:31:27 -0000	1.958
+++ modules/node/node.module	23 Apr 2008 09:40:00 -0000
@@ -336,7 +336,7 @@ function node_teaser($body, $format = NU
   // sentence boundaries.
 
   // The teaser may not be longer than maximum length specified. Initial slice.
-  $teaser = truncate_utf8($body, $size);
+  $teaser = drupal_truncate_chars($body, $size);
 
   // Store the actual length of the UTF8 string -- which might not be the same
   // as $size.
Index: modules/search/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.module,v
retrieving revision 1.254
diff -u -p -r1.254 search.module
--- modules/search/search.module	14 Apr 2008 17:48:41 -0000	1.254
+++ modules/search/search.module	23 Apr 2008 09:40:01 -0000
@@ -394,7 +394,7 @@ function search_index_split($text) {
  * Helper function for array_walk in search_index_split.
  */
 function _search_index_truncate(&$text) {
-  $text = truncate_utf8($text, 50);
+  $text = drupal_truncate_chars($text, 50);
 }
 
 /**
Index: modules/statistics/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.276
diff -u -p -r1.276 statistics.module
--- modules/statistics/statistics.module	16 Apr 2008 11:35:51 -0000	1.276
+++ modules/statistics/statistics.module	23 Apr 2008 09:40:01 -0000
@@ -301,7 +301,7 @@ function statistics_block($op = 'list', 
  */
 function _statistics_link($path, $width = 35) {
   $title = drupal_get_path_alias($path);
-  $title = truncate_utf8($title, $width, FALSE, TRUE);
+  $title = drupal_truncate_chars($title, $width, FALSE, TRUE);
   return l($title, $path);
 }
 
