Simplify shorten_utf8
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@554 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
6d4c0c5377
commit
d044ae0534
|
@ -323,18 +323,8 @@ function select($result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function shorten_utf8($string, $length) {
|
function shorten_utf8($string, $length) {
|
||||||
for ($i=0; $i < strlen($string); $i++) {
|
preg_match("~^(.{0,$length})(.?)~su", $string, $match);
|
||||||
if (ord($string[$i]) >= 192) {
|
return nl2br(htmlspecialchars($match[1])) . ($match[2] ? "<em>...</em>" : "");
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_comment(&$row) {
|
function table_comment(&$row) {
|
||||||
|
|
Loading…
Reference in a new issue