1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-27 17:00:52 +01:00

Do truncation by actual character count.

Using substr can cut a multi-byte character in half.

Also, if a long post with many multi-byte characters was reported, then
the mod interface would temporarily extend the body_truncate_char
setting to be sure to cover all of the *characters* in the report, but
this function would interpret body_truncate_char as a number of *bytes*,
so sometimes the end of the report's appended html would be cut off.
This commit is contained in:
Macil Tech 2013-01-18 18:10:14 -06:00
parent 948dfe8555
commit b63d94838d

View File

@ -170,7 +170,7 @@ function truncate($body, $url, $max_lines = false, $max_chars = false) {
$body = $m[0];
}
$body = substr($body, 0, $max_chars);
$body = mb_substr($body, 0, $max_chars);
if ($body != $original_body) {
// Remove any corrupt tags at the end