Project

General

Profile

Actions

Bug #15797

closed

tx_cms_layout->wordWrapper do not support multi-byte charset

Added by old_hkdennis2k about 18 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend User Interface
Target version:
-
Start date:
2006-03-10
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
3.8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

wordWrapper use chunk_split. which will break multi-byte charset in the middle.
As a result, the db_layout.php of page will show many broken character

It should use wordwrap in CSS. But seem not supported by Firefox.
http://msdn.microsoft.com/workshop/samples/author/dhtml/refs/wordWrap.htm

my edition of it rewrite the logic.
And it assert all incoming character are UTF-8.
(someone please change it to fix)

--- CVS 1.28.2.2 ---
function wordWrapper($content,$max=50,$char=' ') {
$array = split(' |'.chr(10),$content);
foreach($array as $val) {
if (strlen($val)>$max) {
$content=str_replace($val,substr(chunk_split($val,$max,$char),0,-1),$content);
}
}
return $content;
}
--
my edition ---
function wordWrapper($content,$max=50,$char=' ') {
$segments=preg_split("/[\\b\r\n ]/",$content,-1,PREG_SPLIT_DELIM_CAPTURE);
$csConv=$GLOBALS['LANG']
>csConvObj;
foreach($segments as &$segment){
if(strlen($segment)>$max){ // quick check when it is really short
$s=$segment;
$segment='';
while($csConv->strlen('utf-8',$s)>$max){
// It should do better for wide character.
// but csConvObj do not provide that information,
// and browser can do wrap between wide characters
$segment.=$csConv->substr('utf-8',$s,0,$max);
$segment.="\r\n";
$s=$csConv->substr($s,$max);
}
$segment.=$s;
}
}
return implode('',$segments);
}

(issue imported from #M2819)

Actions

Also available in: Atom PDF