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

3
  • Maybe a unicode setting somewhere? idk, so I didn't put it as an answer, stackoverflow.com/questions/5796339/… Commented Oct 9, 2013 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. Commented Oct 9, 2013 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 Commented Oct 9, 2013 at 19:17

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.