Torann / laravel-currency

This provides Laravel with currency functions such as currency formatting and conversion using up-to-date exchange rates.
http://lyften.com/projects/laravel-currency
BSD 2-Clause "Simplified" License
392 stars 137 forks source link

Space or other special characters break formatting #58

Closed imbrish closed 6 years ago

imbrish commented 7 years ago

Function below doesn't give results that one would expect if format involves extra space, dot etc.

currency(12345.6789)

Two examples:

  1. kr 1,0.00kr 12 345,6789
  2. kr. 1,0.00kr. 12.346

Both formats are default so it looks like something doesn't work as it should ;)

dovid commented 7 years ago

I had the same experience with Danish Krone and New Israeli Shekel. I didn't test any others for now.

Torann commented 7 years ago

Is this still an issue? I can't seem to reproduce it. Can you give me an exact example? Like the value you are sending to the method and the currency you are formatting it to along with the output you get and the output you expect.

Example: currency_format('122,433.06', 'DKK')122 433,06 kr.

dovid commented 7 years ago

Yes, I still see this issue. Here's an example.

currency_format('10.00', 'BRL')R$ 10,0000

4nd commented 7 years ago

I think I've fixes this issue, was encountering it with ZAR

The format for ZAR is in as 'R 1,0.00' but from looking at the code, the system works out that the decimal seperator is the , so it looks for this in the string and the number of characters after it denotes the decimal places, so changing this code to 'R 1,0,00' resolves the issue.

Not sure if I've read this right but it fixed it for me for this currency.

Torann commented 7 years ago

Oh perfect. I'll add a fix to the currency format presets. Thank you

csb346 commented 4 years ago

Hi... Did you actually fixed this issue?

I'm still having this problem. For example: ZAR format: R 1,0.00 BRL format: R$ 1,0.00

currency_format(8214.246,'ZAR') => R 8 214,2460 (Should be R 8,214.25) currency_format(8214.246,'BRL') => R$ 8 214,2460 (Should be R$ 8,214.25)

If I remove the space in the format it works fine.

krychu90 commented 3 years ago

Still not fixed