Version 1.1-alpha7()
------------------------------------------------------------------------
+ * Patch mb-functions to better work on foreign/japanese charsets
+ (thanks to deminy!)
+
* Replaced core smarty assign() calls to assign_by_ref() where
appropriate. (Falk Döring, garvinhicking)
TODO: This might introduce oddities! Check thoroughly.
case 'ucfirst':
// there's no mb_ucfirst, so emulate it
if ($mbstring === 2) {
- return mb_strtoupper(mb_substr($args[1], 0, 1)) . mb_substr($args[1], 1);
+ $enc = mb_detect_encoding($args[1]);
+ return mb_strtoupper(mb_substr($args[1], 0, 1, $enc), $enc) . mb_substr($args[1], 1, mb_strlen($args[1], $enc), $enc);
} else {
return ucfirst($args[1]);
}
if ($sql && is_array($sql)) {
foreach($sql AS $key => $row) {
- if ( $serendipity['lang'] == "ja" && function_exists( 'mb_strimwidth')) {
- $comment = mb_strimwidth( strip_tags($row['comment']), 0, $max_chars, " [...]");
+ if (function_exists('mb_strimwidth')) {
+ $comment = mb_strimwidth(strip_tags($row['comment']), 0, $max_chars, " [...]", mb_detect_encoding($row['comment']));
} else {
$comments = wordwrap(strip_tags($row['comment']), $max_chars, '@@@', 1);
$aComment = explode('@@@', $comments);
$user = PLUGIN_COMMENTS_ANONYMOUS;
}
- if ( $serendipity['lang'] == "ja" && function_exists( 'mb_strimwidth')) {
+ if (function_exists( 'mb_strimwidth')) {
$pos = 0;
$parts = array();
- $comment_len = mb_strlen( $comment);
- while ( $pos < $comment_len) {
- $part = mb_strimwidth( $comment, $pos, $wordwrap);
- $pos += mb_strlen( $part);
+ $enc = mb_detect_encoding($comment);
+ $comment_len = mb_strlen($comment, $enc);
+ while ($pos < $comment_len) {
+ $part = mb_strimwidth($comment, $pos, $wordwrap, '', $enc);
+ $pos += mb_strlen($part, $enc);
$parts[] = $part;
}
$comment = implode( "\n", $parts);