I'm using log4net to output a formatted message. The following code
log.DebugFormat("Balance: {0:c} ", balance);
results in
"Balance: ¤1,000.00"
Why is the odd character appearing and not a $
I'm using log4net to output a formatted message. The following code
log.DebugFormat("Balance: {0:c} ", balance);
results in
"Balance: ¤1,000.00"
Why is the odd character appearing and not a $
What does this log for you?
log.Debug(Console.WriteLine(System.Globalization.NumberFormatInfo.GetInstance(null).CurrencySymbol));
I would imagine that it is something to do with your regional settings.
Try something like this:
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(<your culture setting>);
log.DebugFormat("Balance: {0:c} ", balance);
If that dosen't work then you can always use the debugger to check the value of:
System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat;
Specifically check the value of:
ansiCurrencySymbol
To ensure that it's set to the '$' symbol.
You may also be intersted in this wikipedia page: http://en.wikipedia.org/wiki/Currency%5F%28typography%29
Which explains what the symbol you are getting is.
Specifically:
The currency sign (¤) is a character used to denote a currency, when the symbol for a particular currency is unavailable.
It is particularly common in place of symbols, such as that of the Colón (₡), which are absent from most character sets and fonts.
It can be described as a circle the size of a lowercase character with four short radiating arms at 45° (NE), 135° (NW), 225°, (SW) and 315° (SE). It is slightly raised over the baseline.
It is represented in Unicode, as CURRENCY SIGN (U+00A4). In HTML, the character entity reference ¤ or numeric character reference ¤ may be used.