Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

$Content.LimitCharacters - problem with special characters (in translation)

Go to End

2 Posts   6618 Views


Community Member, 1 Post

24 February 2012 at 8:57pm

Howdy folks

I'm having this problem with limiting characters in latest news feature in a multilingual website.

Everything seems to be working ok, except when the last character (ie. limit(10) and the 10 th character) is a special character. It produces character error. This weird question mark. Please see the attached screenshot.

I've charset UTF-8 in _config and template files, so that seems to be ok. To be specific, i'm using scandic letters. Anyone has any ideas, or encountered this kind a behaviour before?

Here's the code in

<% if News %>
<% control News %>

<div class="NewsFront">

<h5><a href="$Link">$MenuTitle</a></h5>


<% end_control %>
<% end_if %>

And here's the function in page.php:

function News($limit = 3) {
	$filter = 'StartPublish < NOW() AND EndPublish > NOW()';
	$order = 'Created DESC';
	return DataObject::get('NewsItem', $filter, $order, null, $limit);

Attached Files

Community Member, 323 Posts

24 February 2012 at 10:01pm


Yes, I’ve already seen it. I guess LimitCharacters is not UTF-8 compliant. I suggest you to find the function somewhere in sapphire (maybe the HTMLText class), put it in your Page class, study how it works and use where needed PHP functions as htmlentities(). You’ll maybe have to use Multibyte String Functions (

Sorry if I’m not being more specific, I’m not a PHP programmer.

Hope it helps,