Culture Specific currency for a given culture

So I was working on a website and I used the following Javascript code

UsdAmount.toLocaleString(siteCulture,
      {style: 'currency', currency: 'USD'})
CadAmount.toLocaleString(siteCulture,
      {style: 'currency', currency: 'CAD'})

      

And it worked great with expected results

So,

Culture     Currency    Output
en-us       USD         $123.45
en-us       CAD         CA$123.45
en-ca       USD         US$123.45
en-ca       CAD         $123.45

      

But this feature doesn't work in Safari, so I can't use it.

So, I suppose I'll just do it server side in C # and pass the string

But this doesn't work for two reasons.

  • I cannot go through two cultures, a systemic culture and a currency culture.
  • Doesn't seem to work since

    4.ToString("C", new CultureInfo("en-us")) ==> "$4.00"
    4.ToString("C", new CultureInfo("en-ca")) ==> "$4.00"  // No CA$
    
          

So, any ideas for a currency formatting that works in all browsers?

+3


source to share


1 answer


If you are running on a server that supports WinRT (Windows 8 or newer), you can use currency formatting , which will do what you want.



0


source







All Articles