View more context

 

Mo

$format = str_replace("\xc2\xa0", ' ', $formatter->formatCurrency(16.66, "EUR")); Seems to fix it

wmk

hmm... where does this come from? What kind of invisible character is that?

Mo

makes sense for a currency as you don't want the symbol moving onto a new line

wmk

Then tell your expected string to have this non-breaking utf-8 space

Mo

I did it the other way round to be honest and stripped it out 😛

Mo

I did consider doing what you suggest, but I had already done it the other way and couldn't be bothered to change it!

Mo

Na, I have a lot of code to carve up, unfortunately that takes precedence 🤨

robbieaverill

i think we need to move away from using number_format in the currency logic in silverstripe soon, in order to support proper i18n for currencies. not sure if that get rid of this problem but it sounds like it would. relevant thread: https://github.com/silverstripe/silverstripe-framework/issues/8216

Show 1 attachment(s)
GitHub  
Currency DBField doesn't allow setting different thousands & decimals separators · Issue #8216 · silverstripe/silverstripe-framework

Affected Version 3., 4. Description In some locales, currencies use different separators, eg in Dutch (Netherlands) we use '€1.000,00' (as opposed to '$1,000.00'). The Currency fiel...

Hide attachment content
👍 (1)
Mo

@robbieaverill I don't think so. I am using NumberFormatter which should format currencies correctly and is used in DBMoney

Mo

Removing number_format from DBCurrency would be great, basically I have had to work around the facy that DBCurrency is not great in most of my code!