Print node body removing html entities? Im printing the node body in my tpl file with this:

 &lt;?php print render(field_view_field("node", $node, "body", array(
  "label"=&gt;"hidden",
  "type" =&gt; "text_summary_or_trimmed",
  "settings"=&gt;array("trim_length" =&gt; 150),
))); ?&gt;


The " and ' characters in the node's content are breaking the page as im putting this in a mailto link. How can I make sure these characters are printed as non html entities eg &amp;#34; instead of ".
You could wrap it in PHP's htmlspecialchars and strip_tags functions:

$body_trimmed = render(field_view_field("node", $node, "body", array(
  "label"=&gt;"hidden",
  "type" =&gt; "text_summary_or_trimmed",
  "settings"=&gt;array("trim_length" =&gt; 150),
))); 
print htmlspecialchars(strip_tags($body_trimmed));


This would give you plain text with special characters encoded.

Alternately, if all you want to do is escape the quote characters and leave the divs in place, you could do a search/replace using str_replace for each, adding the backslash to escape them:

$body_trimmed = render(field_view_field("node", $node, "body", array(
  "label"=&gt;"hidden",
  "type" =&gt; "text_summary_or_trimmed",
  "settings"=&gt;array("trim_length" =&gt; 150),
))); 
$body_trimmed = str_replace("'","\'",$body_trimmed);
$body_trimmed = str_replace('"','\"',$body_trimmed);
print $body_trimmed;