0

I have a Symfony site that includes the ability to print invoices using a Twig template. Customer come from all over the world so I need a way to be able to correctly encode some of the characters that the languages use.

For example, there is a Polish company with 'ę' characters and 'ł' characters. However, Twig is unable to convert these correctly in the print and ends up displaying the following:

Narzï¿1⁄2dzi

instead of

Narzędzi

I've tried using the following ways to convert these in Twig:

companyName|convert_encoding('ISO-8859-1', 'UTF-8')
companyName|convert_encoding('ISO-8859-2', 'UTF-8')
companyName|convert_encoding('UTF-8', 'HTML-ENTITIES') 

As well as various other possible charsets. However, this isn't really ideal anyway, as certain charsets may not work with other languages. Strangely enough, these display fine in the browser by using just:

{{ order.companyName }}

But not when printing.

Is there a way to get around this? Short of changing all the foreign characters, I cannot see how else to do this.

Michael Emerson
  • 1,774
  • 4
  • 31
  • 71

0 Answers0