Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.174
diff -u -p -r1.174 locale.inc
--- includes/locale.inc	9 Jan 2008 21:36:13 -0000	1.174
+++ includes/locale.inc	12 Apr 2008 21:30:23 -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.419
diff -u -p -r1.419 theme.inc
--- includes/theme.inc	2 Apr 2008 20:23:14 -0000	1.419
+++ includes/theme.inc	12 Apr 2008 21:30:24 -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.29
diff -u -p -r1.29 unicode.inc
--- includes/unicode.inc	28 Dec 2007 12:02:50 -0000	1.29
+++ includes/unicode.inc	12 Apr 2008 21:30:24 -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;
+    $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.376
diff -u -p -r1.376 aggregator.module
--- modules/aggregator/aggregator.module	10 Apr 2008 10:28:21 -0000	1.376
+++ modules/aggregator/aggregator.module	12 Apr 2008 21:30:25 -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.459
diff -u -p -r1.459 book.module
--- modules/book/book.module	10 Apr 2008 10:28:22 -0000	1.459
+++ modules/book/book.module	12 Apr 2008 21:30:24 -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.625
diff -u -p -r1.625 comment.module
--- modules/comment/comment.module	10 Apr 2008 10:28:22 -0000	1.625
+++ modules/comment/comment.module	12 Apr 2008 21:30:24 -0000
@@ -1543,7 +1543,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.6
diff -u -p -r1.6 dblog.admin.inc
--- modules/dblog/dblog.admin.inc	8 Jan 2008 10:35:41 -0000	1.6
+++ modules/dblog/dblog.admin.inc	12 Apr 2008 21:30:25 -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.208
diff -u -p -r1.208 filter.module
--- modules/filter/filter.module	11 Apr 2008 02:55:55 -0000	1.208
+++ modules/filter/filter.module	12 Apr 2008 21:30:25 -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.160
diff -u -p -r1.160 menu.module
--- modules/menu/menu.module	10 Apr 2008 10:28:22 -0000	1.160
+++ modules/menu/menu.module	12 Apr 2008 21:30:24 -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.955
diff -u -p -r1.955 node.module
--- modules/node/node.module	10 Apr 2008 10:28:22 -0000	1.955
+++ modules/node/node.module	12 Apr 2008 21:30:25 -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.253
diff -u -p -r1.253 search.module
--- modules/search/search.module	10 Apr 2008 10:28:23 -0000	1.253
+++ modules/search/search.module	12 Apr 2008 21:30:25 -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);
 }
 
 /**
@@ -1233,7 +1233,7 @@ function search_excerpt($keys, $text) {
 
   // If we didn't find anything, return the beginning.
   if (count($ranges) == 0) {
-    return truncate_utf8($text, 256) .' ...';
+    return drupal_truncate_chars($text, 256, FALSE, TRUE);
   }
 
   // Sort the text ranges by starting position.
Index: modules/statistics/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.274
diff -u -p -r1.274 statistics.module
--- modules/statistics/statistics.module	10 Apr 2008 10:28:23 -0000	1.274
+++ modules/statistics/statistics.module	12 Apr 2008 21:30:24 -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);
 }
 
