Re: Proposed change to modifier.truncate.php to respect HTML entities

messju mohr <[email protected]>
Newsgroups gmane.comp.php.smarty.devel
Message-ID <[email protected]>
On Fri, Jun 04, 2004 at 05:35:41PM -0700, Bharat Mediratta wrote:
> 
> I'm using the truncate modifier in my templates to truncate user-defined 
> output which can contain HTML entities.  I need truncate to respect HTML 
> entities so that it calculates the length correctly and doesn't split on 
> HTML entity boundaries.
> 
> I chose to create a new modifier based on the truncate modifier which 
> does the equivalent of html_entity_decode() on the input string, then 
> does the truncate calculation, then does an htmlentities() on the result 
> before returning it.  This is perhaps not the most efficient approach, 
> but it is simple in the code (and I am not particularly concerned about 
> efficiency in this case).
> 
> It would be easy for me to make this an optional behaviour in the 
> standard truncate modifier, preserving its existing API.  If I were to 
> do that and provide a patch, would it be accepted?  If not, is there an 
> alternate approach you'd prefer to get the same results?

html-encoded strings are not the only problematic input to
truncate. AFAIK multi-byte-character-sets can also cause probles.

maybe we can find a solution that solves both?

> thanks,
> -Bharat

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.