I am trying to print amount with currency symbol in console window:
string cultureCode = "hi-IN";//"it-IT";
decimal amount = 123.54M;
CultureInfo cultureInfo = new CultureInfo(cultureCode);
string strAmout=String.Format(cultureInfo, "{0:C}",amount);
Console.OutputEncoding = System.Text.Encoding.UTF8;
Console.WriteLine(strAmout);
Amount is displaying correctly in watch window but not in console window.
On the Home tab, click the Dialog Box Launcher next to Number. Tip: You can also press Ctrl+1 to open the Format Cells dialog box. In the Format Cells dialog box, in the Category list, click Currency or Accounting. In the Symbol box, click the currency symbol that you want.
Select any cell(s) with a numeric value where you want to add a currency symbol. 2. Press and hold down Ctrl + Shift, then press the dollar sign (4). The shortcut is to apply the Currency format with two decimals and thousands separator (,).
The encoding you're using for your output might not include those currency symbols.
try setting the output encoding of your console to one that supports the currency symbol :
Console.OutputEncoding = System.Text.Encoding.UTF8
It is by design.
Console window is displayed using some special font (Lucida Console, Consolas and so on).
That font not necessary has symbol for your currency, so that symbol can be displayed incorrectly.
UPDATE
According to this link, rupee sign is not supported in Lucida Console
font.
According to this link, it is supported in Consolas
font.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With