在.NET应用程序中获取通用货币符号而不是$
在我们的 VB .NET 应用程序中,我们使用“c0”和“c2”格式字符串来显示各处的货币值。
最近,用户遇到了以下问题:这些货币值无法正确显示 $ 符号,而是显示一些奇怪的符号 ¤。通过维基百科,我发现它是通用货币符号: http://en.wikipedia.org /wiki/Currency_(typography)
我曾经在我的机器上看到过这个问题,并且从那以后就无法重新创建它。当我重新启动应用程序时它就消失了。事实上,我一看到问题,就启动了应用程序的另一个实例,但 $ 符号在第二个实例中显示正常。
如果您能提供有关如何解决这个奇怪问题的任何见解,我将不胜感激。
In our VB .NET application, we use "c0" and "c2" format strings to display currency values all over the place.
Recently, users have had issues where these currency values don't show up correctly with a $ sign, but with some weird symbol, ¤. Through wikipedia, I found out it's the generic currency symbol: http://en.wikipedia.org/wiki/Currency_(typography)
I've seen the problem happen on my machine ONCE, and haven't been able to recreate it since. It went away when I restarted the application. In fact, as soon as I saw the problem, I started another instance of the application but $ signs showed up fine in that second instance.
I'd appreciate any insights on how to fix this weird issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们终于找到了一个始终出现此问题的版本。
事实证明,我们使用 RedGate SQL Compare 来比较和更新用户的数据库,而 RedGate 中的一个错误将我们的 Globalization.CultureInfo.CurrentCulture 从“en-US”更改为“”。这又将 Globalization.CultureInfor.CurrentCulture.NumberFormat.CurrencySymbol 更改为通用符号 ¤。
我仍然不清楚为什么问题发生在某些数据库而不是其他数据库上,但我们确实找到了解决方法。
RedGate 问题是在以下论坛主题中发现的:http://www. red-gate.com/messageboard/viewtopic.php?t=10864 并自其 2011 年 3 月版本
We finally got hold of a build where this problem happened consistently.
Turned out, we use RedGate SQL Compare to compare and update users' databases, and it was a bug in RedGate that changed our Globalization.CultureInfo.CurrentCulture from "en-US" to "". That in turns changed the Globalization.CultureInfor.CurrentCulture.NumberFormat.CurrencySymbol to the generic sign ¤.
I'm still unclear as to why the issue happened with some databases and not others, but we've certainly found our workaround.
The RedGate problem was identified in this forum thread: http://www.red-gate.com/messageboard/viewtopic.php?t=10864 and has been fixed since their March 2011 release
在使用格式字符串之前,您可能需要显式设置格式区域设置。
You may need to explicitly set the format locale before using your format strings.