Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Currency symbol is not displaying in console window

Tags:

c#

.net

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.

like image 414
Arshad Avatar asked Dec 17 '14 12:12

Arshad


People also ask

How do you insert the currency symbol in Word?

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.

How do I create a currency shortcut in Excel?

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


2 Answers

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
like image 57
Timothy Groote Avatar answered Sep 20 '22 00:09

Timothy Groote


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.

like image 41
Andrey Korneyev Avatar answered Sep 18 '22 00:09

Andrey Korneyev