Question

I want to display an amount with the Nigerian currency symbol (i.e N with double strike through "").

I've tried the ff piece of code which only displays the amount with just N and not with the properly symbol(N with double strike through )

@{ IFormatProvider currencyFormat = new System.Globalization.CultureInfo("HA-LATN-NG"); }

Amount: @string.Format(currencyFormat, "{0:c}", Model.Amount) <br />

Any ideas how to achieve it?

Était-ce utile?

La solution

It looks like the built-in nigerian cultures have a straight english N as their currency symbol. You can override that to use the Naira sign instead:

var formatter = new System.Globalization.CultureInfo("HA-LATN-NG");
formatter.NumberFormat.CurrencySymbol = "₦";

After this all formatting with formatter will use the desired symbol, but be aware that the character also needs to be supported by the font the website renders in. Some fonts may not include the symbol or they might include a different symbol in its place (I have seen this on my local machine).

Autres conseils

It looks like the symbol used in the CultureInfo is just an "N". To view the proper version, you can use this shortcut.

char x = (char)8358;
MessageBox.Show(x.ToString());
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top