1
0

Always assume UTF-8.

This commit is contained in:
2022-02-20 17:14:54 +01:00
parent b1c43491c3
commit 4785f07f12
61 changed files with 110 additions and 278 deletions
bundled-libs/Onyx
comment.php
include
index.php
lang/UTF-8
lib/LuckyCoin
plugins
serendipity_event_gravatar
serendipity_event_spartacus
serendipity_event_xhtmlcleanup
serendipity_plugin_comments
serendipity_plugin_remoterss
serendipity.css.phpserendipity_admin.phpserendipity_admin_image_selector.phpserendipity_config.inc.php
templates

@ -204,7 +204,7 @@ class serendipity_plugin_comments extends serendipity_plugin
}
# truncate comment to $max_chars
if (function_exists('mb_strimwidth')) {
$comment = mb_strimwidth($comment, 0, $max_chars, " [...]", LANG_CHARSET);
$comment = mb_strimwidth($comment, 0, $max_chars, " [...]", 'UTF-8');
} else {
$comments = wordwrap($comment, $max_chars, '@@@', 1);
$aComment = explode('@@@', $comments);
@ -242,22 +242,21 @@ class serendipity_plugin_comments extends serendipity_plugin
if (function_exists('mb_strimwidth') && function_exists('mb_strrpos') && function_exists('mb_substr')) {
$pos = 0;
$parts = array();
$enc = LANG_CHARSET;
$comment_len = mb_strlen($comment, $enc);
$comment_len = mb_strlen($comment);
# iterate over the (truncated) comment and wrap each line at $wordwrap
while ($pos < $comment_len) {
# do we still need to wrap this line or is it shorter than $wordwrap?
if ($comment_len - $pos > $wordwrap) {
# location of first space
$spacepos = mb_strrpos(mb_substr($comment, $pos, $wordwrap, $enc), ' ', $enc);
$spacepos = mb_strrpos(mb_substr($comment, $pos, $wordwrap), ' ');
# wrap at word boundary if we have at least one space
$part = ( $spacepos > 0 ) ? mb_substr($comment, $pos, $spacepos, $enc) : mb_strimwidth($comment, $pos, $wordwrap, '', $enc);;
$part = ( $spacepos > 0 ) ? mb_substr($comment, $pos, $spacepos) : mb_strimwidth($comment, $pos, $wordwrap, '');;
} else {
# wrap "hard", i.e. truncate words that are too long
$part = mb_substr($comment, $pos, $wordwrap, $enc);
$part = mb_substr($comment, $pos, $wordwrap);
}
# forward the pointer
$pos += mb_strlen($part, $enc);
$pos += mb_strlen($part);
# remove leading spaces
$part = ltrim($part);
# re-assemble the lines, i.e. add our current line
@ -298,4 +297,4 @@ class serendipity_plugin_comments extends serendipity_plugin
}
/* vim: set sts=4 ts=4 expandtab : */
?>
?>