aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/utf
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2007-08-16 11:28:58 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2007-08-16 11:28:58 +0000
commitc9dcf849b9d196f27131c21b79ebf1793f3c1cda (patch)
treebca8bb4b6ad03be4fd4534f2e3d423ffd66371c5 /phpBB/includes/utf
parent2bbd2fb1f97d4668e82c26badbe89c3d3fdc8169 (diff)
downloadforums-c9dcf849b9d196f27131c21b79ebf1793f3c1cda.tar
forums-c9dcf849b9d196f27131c21b79ebf1793f3c1cda.tar.gz
forums-c9dcf849b9d196f27131c21b79ebf1793f3c1cda.tar.bz2
forums-c9dcf849b9d196f27131c21b79ebf1793f3c1cda.tar.xz
forums-c9dcf849b9d196f27131c21b79ebf1793f3c1cda.zip
- two new packages... diff and utf
- only 60 chars for topic title if new post (please see changelog for explanation) - change utf8_wordwrap (had some bugs david and nils spotted - was not really functional, sorry for this. :D) git-svn-id: file:///svn/phpbb/trunk@8034 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/utf')
-rw-r--r--phpBB/includes/utf/utf_normalizer.php4
-rw-r--r--phpBB/includes/utf/utf_tools.php53
2 files changed, 33 insertions, 24 deletions
diff --git a/phpBB/includes/utf/utf_normalizer.php b/phpBB/includes/utf/utf_normalizer.php
index 3332f3f744..4c705b05cb 100644
--- a/phpBB/includes/utf/utf_normalizer.php
+++ b/phpBB/includes/utf/utf_normalizer.php
@@ -1,7 +1,7 @@
<?php
/**
*
-* @package phpBB3
+* @package utf
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -57,7 +57,7 @@ define('UNICODE_JAMO_T', 2);
/**
* Unicode normalization routines
*
-* @package phpBB3
+* @package utf
*/
class utf_normalizer
{
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php
index 9ee39570a9..f8156fb8d2 100644
--- a/phpBB/includes/utf/utf_tools.php
+++ b/phpBB/includes/utf/utf_tools.php
@@ -1,7 +1,7 @@
<?php
/**
*
-* @package phpBB3
+* @package utf
* @version $Id$
* @copyright (c) 2006 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -24,7 +24,7 @@ setlocale(LC_CTYPE, 'C');
* Whenever possible, these functions will try to use PHP's built-in functions or
* extensions, otherwise they will default to custom routines.
*
-* @package phpBB3
+* @package utf
*/
if (!extension_loaded('xml'))
@@ -1874,35 +1874,44 @@ function utf8_convert_message($message)
*/
function utf8_wordwrap($string, $width = 75, $break = "\n", $cut = false)
{
- // If cutting, we just split by $width chars
- if ($cut)
- {
- return implode($break, utf8_str_split($string, $width));
- }
-
- // If not cutting, we first need to explode on spacer and then merge
- $words = explode(' ', $string);
- $lines = array();
+ // We first need to explode on $break, not destroying existing (intended) breaks
+ $lines = explode($break, $string);
+ $new_lines = array(0 => '');
$index = 0;
- foreach ($words as $word)
+ foreach ($lines as $line)
{
- if (!isset($lines[$index]))
- {
- $lines[$index] = '';
- }
+ $words = explode(' ', $line);
- if (!empty($lines[$index]) && utf8_strlen($lines[$index]) > $width)
+ for ($i = 0, $size = sizeof($words); $i < $size; $i++)
{
- $lines[$index] = substr($lines[$index], 0, -1);
- $index++;
- $lines[$index] = '';
+ $word = $words[$i];
+
+ // If cut is true we need to cut the word if it is > width chars
+ if ($cut && utf8_strlen($word) > $width)
+ {
+ $words[$i] = utf8_substr($word, $width);
+ $word = utf8_substr($word, 0, $width);
+ $i--;
+ }
+
+ if (utf8_strlen($new_lines[$index] . $word) > $width)
+ {
+ $new_lines[$index] = substr($new_lines[$index], 0, -1);
+ $index++;
+ $new_lines[$index] = '';
+ }
+
+ $new_lines[$index] .= $word . ' ';
}
- $lines[$index] .= $word . ' ';
+ $new_lines[$index] = substr($new_lines[$index], 0, -1);
+ $index++;
+ $new_lines[$index] = '';
}
- return implode($break, $lines);
+ unset($new_lines[$index]);
+ return implode($break, $new_lines);
}
?> \ No newline at end of file