Pregunta

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?

¿Fue útil?

Solución

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).

Otros consejos

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());
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top