Skip to content

Commit

Permalink
Simplify shorten_utf8
Browse files Browse the repository at this point in the history
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@554 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information
jakubvrana committed Feb 6, 2009
1 parent 6d4c0c5 commit d044ae0
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions functions.inc.php
Expand Up @@ -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) {
Expand Down

0 comments on commit d044ae0

Please sign in to comment.