PHP SDK - Render Rich-Text Doesn't Encode Special Characters

With the PHP SDK, I’m using a basic content type with a rich-text field for “bodyContent”. Like so:

$renderer = new \Contentful\RichText\Renderer();
$renderedHTML = $renderer->render($content->get(‘bodyContent’));

And then I output $renderedHTML to the page. However, I noticed that if a content author types in special characters like an ampersand, greater-than, less-than signs, or double quote marks…they don’t get encoded by the Renderer() class.

I can just run an htmlspecialchars() over the results either, because then it will escape the actual HTML elements like paragraph tags, heading tags, links, etc.

Is there a means to properly encode HTML content from rich-text?

Sorry, everyone! I realize my mistake here. The Renderer() is encoding things properly.

I had been remembering that I (understandably) had to run htmlspecialchars() on regular text fields. That was in my mind while I was moving on to the rich-text field I needed, so when I was trying to confirm the Renderer was encoding things I used the Chrome Developer Tools “Inspect” and it appeared to not be encoded…but I forgot that “Inspect” decodes… When I “View Source” instead, I can see that the PHP SDK is properly encoding things for me.