Browse files

Simplify shorten_utf8

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@554 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent 6d4c0c5 commit d044ae0534800c41f1e8c1e875408cadc9a6a967 jakubvrana committed Feb 6, 2009
Showing with 2 additions and 12 deletions.
  1. +2 −12 functions.inc.php
View
14 functions.inc.php
@@ -323,18 +323,8 @@ function select($result) {
}
function shorten_utf8($string, $length) {
- for ($i=0; $i < strlen($string); $i++) {
- if (ord($string[$i]) >= 192) {
- while (ord($string[$i+1]) >= 128 && ord($string[$i+1]) < 192) {
- $i++;
- }
- }
- $length--;
- if ($length == 0) {
- return nl2br(htmlspecialchars(substr($string, 0, $i+1))) . "<em>...</em>";
- }
- }
- return nl2br(htmlspecialchars($string));
+ preg_match("~^(.{0,$length})(.?)~su", $string, $match);
+ return nl2br(htmlspecialchars($match[1])) . ($match[2] ? "<em>...</em>" : "");
}
function table_comment(&$row) {

0 comments on commit d044ae0

Please sign in to comment.