-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
MoneyType renders incorrect symbol for currency € when serving pages in ISO-8859-15 #25135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think the issue comes from NumberFormatter returning a UTF-8 encoded string. Which is not properly converted to ISO. echo htmlentities(iconv('UTF-8', 'ISO-8859-15', $pattern), \ENT_HTML5, 'ISO-8859-15'); should do. |
Sorry, I need some context, do you mean I should use this in a template to override default rendering? |
not sure yet. The issue seems to happen from SF (sure you can fix it somewhere in a override). Im not fully sure how to move forward, assuming we already do htmlspecialchars by default in twig against the current charset (in your case ISO-...), but that doesnt help with In general i think the steps for SF in MoneyType are roughly;
|
What could be done is accounting for the fact that Intl returns UTF-8 things, and so converting it: {{ foo|convert_encoding(_charset, 'UTF-8') }} However, I suggest you to do it in a custom form theme instead of changing the form theme in Symfony. Applying iconv for all people actually using UTF-8 would have overhead (and UTF-8 is the default). |
we could convert on the fly no? if needed. {% if _charset != 'UTF-8' %}
{{ foo|convert_encoding(...) }}
{% endif %} Did not
8000
know about |
@ro0NL I'm not sure having lots of |
we could do it from MoneyType =/
Tend to agree; but a fix might be nice / solving this issue (should we close?). |
Sure it isn't, in my case, it's a new Symfony module over a legacy app, so we are forced to apply legacy charset |
This looks like a bug to me. I would expect at least |
Actually, ISO-8859-15 has the Euro symbol as |
@derrabus you're right, however |
ISO-8859-1 is deprecated and 8859-15 is supposed to replace it. Both charsets are similar enough, so you can read ISO 5559-1 encoded data and treat it as ISO-8859-15. The difference is that eight character codes have been reassigned.
I agree. If you can switch to HTML entities in a non-breaking way, go for it. |
This PR was squashed before being merged into the 2.7 branch (closes #26663). Discussion ---------- [TwigBridge] Fix rendering of currency by MoneyType | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | todo | Fixed tickets | #25135 | License | MIT | Doc PR | - Split from #25167 as suggested by @nicolas-grekas to see if this can be reasonably fixed on 2.7, the right way using this itsy-bitsy new feature. #25167 still contains some valuable changes regarding tests. Ill continue either one PR depending on the target branch / proposed fix. Commits ------- a3a2ff0 [TwigBridge] Fix rendering of currency by MoneyType
When serving pages in charset ISO-8859-15 instead of default UTF-8 and rendering a form MoneyType, currency symbol (€ in my case) is shown in wrong codification (see screen captures).
As additional information, this is my code in
AppKernel.php
regarding charset:And a link showing details of ISO-8859-15 charset, which supposedly has an euro (€) symbol. My twig template is also encoded in ISO-8859-15. A possible cause of this problem is that the source code file for money template is encoded in UTF-8, which is of course right.
I know I can override MoneyType template, but a correct solution, I think, is writing the euro symbol as the
€
html entity, which is charset independant.The text was updated successfully, but these errors were encountered: