SYMFONY – TWIG UTF-8 encoding of raw content

The controller passes the array to the branch template. The array contains the correct UTF-8 encoded strings. I can check this with var_dump($theArray) in the controller. All strings Are displayed correctly.

But on the branch

{% for video in videos %}
{{ video.title_value | raw })

{% endfor %}

Some characters such as Ö, Ä, Ü are replaced by this replacement. Controller and template encoding is UTF-8, no BOM and

Already set. Must do raw output because the string may contain html tags. Know how to fix it?

I’m not sure if your source data is actually UTF-8 encoded. Only use var_dump () is not enough to verify the encoding of the content.

Try to use Firefox or Chrome to echo/dump the content and view the page, and change the encoding to UTF-8, then change the other content to ISO -8859-1. If the content looks wrong when you choose UTF-8, then your content is not UTF-8 encoded.

>To change the encoding in Firefox: View>Character encoding>To change Encoding in Chrome: Tools>Encoding

The controller passes the array to the branch template. The array contains the correct UTF-8 encoded string. I can in the controller Check this with var_dump($theArray). All strings are displayed correctly.

But on the branch

{% for video in videos %}
{{ video.title_value | raw }}

{% endfor %}

Some characters such as Ö, Ä, Ü are replaced by this replacement. Controller and The template encoding is UTF-8, no BOM and

 

Already set. I have to do raw output because the string may contain html tags. Know how to fix it?

I’m not sure if your source data is actually UTF-8 encoded. Using var_dump() alone is not enough to verify the encoding of the content.

Try to use Firefox or Chrome to echo/dump the content and view the page, and change the encoding to UTF-8, and then change the other content to ISO-8859-1. If you choose UTF-8 The content looks wrong, then your content is not UTF-8 encoded.

>To change the encoding in Firefox: View>Character encoding>To change the encoding in Chrome: Tools>Encoding

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4926 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.