Jump to content

Problem with smarty truncate modifier, html entities and utf-8


Recommended Posts

I discovered that the truncate modifier in smarty did not work properly with the Danish national characters æ, ø and å. I found out that the problem was in tools/smarty/plugins/modifier.truncate.php.

If found an html_strlen and an html_substr function in the PHP manual and also put in mb_substr to fix this. It probably won't do to hard code "utf-8" in smarty in general, but it cured my (PrestaShop's?) problem.

I have attached modifier.truncate.php.

/Kjeld

modifier.truncate.php

  • Like 1
Link to comment
Share on other sites

Yes, this fixes problems with æ, ø and å (and a lot of other non-7-bit-ASCII characters). E.g. when you put an item in the basket, the last letter could look like �. Also, the length of the shortened texts were often less than expected. E.g. the letter "å" should have a length of 1 but the length was calculated to 7 (the length of "å").

/Kjeld

Link to comment
Share on other sites

  • 2 weeks later...
  • 7 years later...
  • 7 months later...
×
×
  • Create New...