? taxonomy.module_3.diff
? includes/kdialog
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.438
diff -u -F^f -r1.438 common.inc
--- includes/common.inc	28 Apr 2005 19:23:19 -0000	1.438
+++ includes/common.inc	29 Apr 2005 14:50:51 -0000
@@ -921,12 +921,7 @@ function format_name($object) {
 
   if ($object->uid && $object->name) {
     // Shorten the name when it is too long or it will break many tables.
-    if (strlen($object->name) > 20) {
-      $name = truncate_utf8($object->name, 15) .'...';
-    }
-    else {
-      $name = $object->name;
-    }
+    $name = truncate_utf8_conc($object->name, 20)
 
     if (user_access('access user profiles')) {
       $output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
@@ -1716,6 +1711,37 @@ function truncate_utf8($string, $len, $w
 }
 
 /**
+ * Truncate a UTF-8-encoded string safely and append it with a string, if truncated.
+ *
+ * If the end position is in the middle of a UTF-8 sequence, it scans backwards
+ * until the beginning of the byte sequence.
+ *
+ * Use this function whenever you want to chop off a string at an unsure
+ * location, and want to append it with a string. For example to turn the long username
+ * johndoe@www.personalweblog.com into johndoe@www.johndo...
+ *
+ * @param $string
+ *   The string to truncate.
+ * @param $len
+ *   An upper limit on the returned string length.
+ * @param $postfix
+ *   string to append to the trunkated string. Defaults to "..."
+ * @return
+ *   The truncated string.
+ */
+function truncate_utf8_conc($string, $len, $postfix = '...') {
+  //return non truncated, when smaller then $len plus the amount of chars to be concenated.
+  if (strlen($string) <= ($len + strlen($postfix))) {
+    return $string;
+}
+  if ((ord($string[$len]) < 0x80) || (ord($string[$len]) >= 0xC0)) {
+    return substr($string, 0, $len) . $postfix;
+}
+  while (ord($string[--$len]) < 0xC0) {};
+  return substr($string, 0, $len) . $postfix;
+}
+
+/**
  * Encodes MIME/HTTP header values that contain non US-ASCII characters.
  *
  * For example, mime_header_encode('tést.txt') returns "=?UTF-8?B?dMOpc3QudHh0?=".
Index: modules/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search.module,v
retrieving revision 1.124
diff -u -F^f -r1.124 search.module
--- modules/search.module	11 Apr 2005 22:48:27 -0000	1.124
+++ modules/search.module	29 Apr 2005 14:50:52 -0000
@@ -764,7 +764,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 truncate_utf8_conc($text, 256);
   }
 
   // Sort the text ranges by starting position.
