Always assume UTF-8.
This commit is contained in:
bundled-libs/Onyx
comment.phpinclude
admin
compat.inc.phpfunctions.inc.phpfunctions_comments.inc.phpfunctions_images.inc.phpfunctions_permalinks.inc.phpfunctions_smarty.inc.phpfunctions_trackbacks.inc.phptemplate_api.inc.phplang/UTF-8
serendipity_lang_bg.inc.phpserendipity_lang_cn.inc.phpserendipity_lang_cs.inc.phpserendipity_lang_cz.inc.phpserendipity_lang_da.inc.phpserendipity_lang_de.inc.phpserendipity_lang_en.inc.phpserendipity_lang_es.inc.phpserendipity_lang_fa.inc.phpserendipity_lang_fi.inc.phpserendipity_lang_fr.inc.phpserendipity_lang_hu.inc.phpserendipity_lang_is.inc.phpserendipity_lang_it.inc.phpserendipity_lang_ja.inc.phpserendipity_lang_ko.inc.phpserendipity_lang_nl.inc.phpserendipity_lang_no.inc.phpserendipity_lang_pl.inc.phpserendipity_lang_pt.inc.phpserendipity_lang_pt_PT.inc.phpserendipity_lang_ro.inc.phpserendipity_lang_ru.inc.phpserendipity_lang_sa.inc.phpserendipity_lang_se.inc.phpserendipity_lang_sk.inc.phpserendipity_lang_ta.inc.phpserendipity_lang_tn.inc.phpserendipity_lang_tr.inc.phpserendipity_lang_tw.inc.phpserendipity_lang_zh.inc.php
lib/LuckyCoin
plugins
serendipity_event_gravatar
serendipity_event_spartacus
serendipity_event_xhtmlcleanup
serendipity_plugin_comments
serendipity_plugin_remoterss
templates
2k11
clean-blog
default
@ -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 : */
|
||||
?>
|
||||
?>
|
||||
|
Reference in New Issue
Block a user