1

I try to format a string in a powershell 3 console like so:

PS C:\> "price : {0:C}" -f 15,99
price : ? 15,00

Instead of displaying the currency sign, I get a "?".

If I do the same command in ISE, the windows powershell IDE, I get:

PS C:\> "price : {0:C}" -f 15,99
price : € 15,00

Why is this? Do I need to enable a setting for the console session?

-Darrell

Shay Levy
  • 121,444
  • 32
  • 184
  • 206
DeChinees
  • 295
  • 6
  • 20
  • Maybe a unicode setting somewhere? idk, so I didn't put it as an answer, http://stackoverflow.com/questions/5796339/printing-unicode-characters-to-powershell-prompt – MDMoore313 Oct 09 '13 at 12:49
  • Have you checked the font settings of your console, to ensure that the font includes the Euro symbol? It could be simply a rendering issue. – TRayburn Oct 09 '13 at 15:31
  • Not sure if this is relevant, but also note that `15,99` in Powershell-land is an array of two ints, containing entries 15 and 99. Your format string contains only one slot, so only the 15 is used. It is not the single number "15 and 99/100", which I realize in Euro-style is often written "15,99". If you want that number, you need to use `15.99` – latkin Oct 09 '13 at 19:17

2 Answers2

3

I would check your font settings, I was just able to reproduce the described behavior by setting my PowerShell console font to "Raster Fonts". If you set to either Lucida or Consolas this behavior does not reproduce.

TRayburn
  • 1,535
  • 12
  • 10
0

This looks like a bug to me. The format is pulled from [System.Globalization.NumberFormatInfo]::CurrentInfo.CurrencySymbol

[System.Globalization.NumberFormatInfo]::CurrentInfo.CurrencySymbol
"price : {0:C}" -f 15,99
[System.Globalization.NumberFormatInfo]::CurrentInfo.CurrencySymbol="€"
"price : {0:C}" -f 15,99
Dirk
  • 666
  • 6
  • 5