I am developing a news system for a french association's website with Symfony2. I'm having troubles when it comes to displaying the accents and also HTML.
In the twig view I simply output the variable:
{{ article.body }}
If I insert the accent directly in the database like this: 'é', the variable is not even displayed.
If I insert this instead: é
it stays the same.
HTML is shown as text.
I also tried the autoescape
function (set to true
and false
), no success :
{% autoescape true %}
{{ article.body }}
{% endautoescape %}
Any suggestions? Thanks a lot
First you need setting the charset in your HTML code
Second "convert_encoding()" is a twig function which convert variable to other encoding.
But maybe, you need to use raw before convert your variable
http://twig.sensiolabs.org/doc/filters/convert_encoding.html
Try this, if you have in the ddbb something like this
This will show
Encoding problem could appear in the next places:
The HTML document:
Try to convert the twig files and controllers into UTF-8! The similar problem was here (when passing variables from the controller to twig), and this solved the problem.