Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I display Nigerian Naira symbol in CultureInfo(c#)

Tags:

c#

cultureinfo

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?

like image 558
sirbombay Avatar asked Dec 12 '25 05:12

sirbombay


2 Answers

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

like image 192
Jon Avatar answered Dec 13 '25 18:12

Jon


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());
like image 44
Sean Kornish Avatar answered Dec 13 '25 19:12

Sean Kornish