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

老子叫甜甜 提交于 2019-12-30 10:37:26

问题


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?


回答1:


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




回答2:


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());


来源:https://stackoverflow.com/questions/18716571/how-do-i-display-nigerian-naira-symbol-in-cultureinfoc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!