chakroun yesser
chakroun yesser

Reputation: 1487

Symfony 2 Twig UTF-8 Accents Encoding

This is a code exemple from my twig file

<h3>Some Data With accents é è ô</h3>
    {{ data_from_controller | raw }}

the text is replaced by special characters =>

but When Data is provided from database there is no problem with accents

My Encoding is UTF-8

Result :

<h3>Some Data With accents � � �</h3>
<span>data from database->controller exemple : é à è ... </span>
<span>data from controller without database : � � � ... </span>

Any one know why?

Upvotes: 1

Views: 4532

Answers (2)

Nilton Mamani Peralta
Nilton Mamani Peralta

Reputation: 11

<meta charset="UTF-8" />
<td>
    {{ report.name| raw | convert_encoding('UTF-8', 'ISO-8859-1') }}
</td>

Upvotes: 0

sf_tristanb
sf_tristanb

Reputation: 8855

Check that in your IDE (netbeans, notepad++...) that you are UTF-8 compliant. It means that you have to be sure that each time you save your files, it saves it with the UTF-8 (Without BOM) encoding.

If your controller file are saved in a non UTF8 encoding, and twig is configured to display UTF8, it'll result in your problem.

Upvotes: 4

Related Questions