Categories > TinyButStrong general >

max= and special chars

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: res
Date: 2004-03-14
Time: 14:22

max= and special chars

"max" parametr doesn't work correctly with html special chars like   ©, &#xxx; (symbols), etc. Is there any solution, how to solve it?
Thank you.
By: RwD
Date: 2004-03-14
Time: 14:29

Re: max= and special chars

perhaps as a temorary solution you can replace them by the actual characters first?

  is ascii 160 by the way and is displayed correctly by browsers
By: res
Date: 2004-03-14
Time: 15:52

Re: max= and special chars

i cant. This codes I use for char codes for multilanguage site (there is some chars in another langiage). I can't describe full reason (my english:))
By: res
Date: 2004-03-14
Time: 15:53

Re: max= and special chars

and it will not safe, if ill replace for example &gt; and &&lt; with < and >
By: RwD
Date: 2004-03-14
Time: 16:41

Re: max= and special chars

hmm, I see... I had this problem ones too with another program...

Lets see if I can fit the solution to tbs, perhaps Skrol29 will take over this in the actual tbs :D (If I am able to change it)
By: RwD
Date: 2004-03-14
Time: 17:34

Re: max= and special chars

I found the place where I think the max length is regulated.
It was at line 701:
//MaxLength
if (isset($Loc->PrmLst['max'])) {
    $x = intval($Loc->PrmLst['max']) ;
    if (strlen($CurrVal)>$x) {
        $CurrVal = substr($CurrVal,0,$x-1).'...' ;
    }
}

you could replace it like this:
//MaxLength
if (isset($Loc->PrmLst['max'])) {
    $x = intval($Loc->PrmLst['max']) ;
    if (strlen($CurrVal)>$x) {
        $CurrVal = substr(html_entity_decode($CurrVal),0,$x-1).'...' ;
        $CurrVal = htmlentities($CurrVal);
    }
}

I haven't tested that, please see www.php.net to see about the functions html_entity_decode & htmlentities.

Please note that html_entity_decode is PHP 4.3.0 and up only...
By: RwD
Date: 2004-03-14
Time: 17:36

Re: max= and special chars

little error, the strlen check should also check the string without entities.

So use this instead
//MaxLength
if (isset($Loc->PrmLst['max'])) {
    $x = intval($Loc->PrmLst['max']) ;
    if (strlen(html_entity_decode($CurrVal))>$x) {
        $CurrVal = substr(html_entity_decode($CurrVal),0,$x-1).'...' ;
        $CurrVal = htmlentities($CurrVal);
    }
}
By: Skrol29
Date: 2004-03-14
Time: 18:03

Re: max= and special chars

But html_entity_decode() is supported only for PHP >= 4.3.0
By: RwD
Date: 2004-03-14
Time: 18:18

Re: max= and special chars

I know, I put that in my reply ;)
By: Skrol29
Date: 2004-03-16
Time: 02:22

Re: max= and special chars

Hi,

Your problem will be fixed in the next version.
It is coming soon (before the end of the week).
By: res
Date: 2004-03-16
Time: 18:20

Re: max= and special chars

cool. *waiting for the new version *
:-)