[Typo3-dev] crop whole words and utf-8 SOLVED

Toni Milovan tmilovan at efpu.hr
Fri Nov 11 20:00:36 CET 2005


Hi to all that helped. 

I have finally managed to solve this problem:

The problem generally is that tt_news does not use standard crop
function from class.tslib_content.php, but crop function from
class.t3lib_cs.php instead. 

And while this function has utf-8 handling built in, it does not have a
possibility to accept third parameter for croping of whole words.

Even more, it seems that tt_news does not forwards charset parameter to
this function. That leaves us with function that does not recognize
charset (which is not always the problem, but it is with utf-8), and
which is not able to cut out whole words.

The first problem (whole word cropping) is solveable by adding something like this:
                        if ($len > 0)   {
                                if (strlen($string{$i}))        {
                                        $string = substr($string, 0, $i);
                                        $pos = strrpos($string, " ");
                                        if($pos === false) {
                                                return substr($string, 0, $i);
                                        } else {
                                                return substr($string, 0, $pos).$crop;

                                        }
                                }
					   } else {
							....
					   }
						
... at the correct place somewhere below the line 1414 at
class.t3lib_cs.php
This works fine for me.

The second problem will have to resolve someone from tt_news team by
adding correct function call when calling crop function. I have forced
crop function to always act as if we have utf-8, but that of course is
not a good way to do it.

However, if you urgently need a solution you can do it like I did.

Wolfgang and Christian suggested that crop function should be called
from class.tslib_content.php, and maybe that is the right solution
because it seems that function call in tt_news is actually designed for
this function but I don't know how well will this function handle utf-8.

So, that's it. If I did get something wrong please correct me before I
fill bugreport.

Thanks,

Toni





On Pet, 2005-11-11 at 12:45 +0100, Toni Milovan wrote:
> Hi,
> 
> I'm posting this here after discussion on typo3 userlist:
> 
> I'm trying to force crop function to preserve whole words but no matter
> how do I put it it breaks the words. Eg.:
> 
> plugin.tt_news.displayList.subheader_stdWrap.crop = 80 | ... | 0
> 
> or
> 
> plugin.tt_news.displayList.subheader_stdWrap.crop = 80 | ... | 1
> 
> ... the resulting crop is always the same. 
> 
> Now, Im using the utf-8 charset and after discussion on typo userlist we
> concluded that problem is probably in utf-8 being multibyte enconding. 
> 
> I'm interested (if that is the case) has this problem been solved in
> development versions and is that problem solveable at all?
> 
> Thanks 
> 
> Toni
> 
> 
> _______________________________________________
> Typo3-dev mailing list
> Typo3-dev at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev
-- 
Toni Milovan <tmilovan at efpu.hr>





More information about the TYPO3-dev mailing list