带小数点分隔符的本地化
.NET 是否有可能在服务器 A 上使用“,”作为小数分隔符,而在另一个服务器 B 上使用“.”? + 你如何检测到这一点?
将字符串转换为双精度数时,在服务器 A 上一切正常,但在服务器 B 上我们遇到问题。
示例:
服务器 A:20,4 --> 20.4 服务器B:20,4 --> 204
我们需要检测到这一点,以便两台服务器上的东西都能继续工作。
谢谢,利文·卡登
Is it possible that .NET uses on server A ',' as decimal separator and on another server B '.'? + How can you detect this?
When converting strings to doubles, on server A everything works fine, but on server B we have problems.
Example:
server A : 20,4 --> 20.4
server B : 20,4 --> 204
We would need to detect this so that on both servers things keep on working.
thx, Lieven Cardoen
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来好像在一台服务器上正确设置了区域设置,但在另一台服务器上则不然。
有几种方法可以做到这一点,但您可能希望使用 Thread.CurrentThread.CurrentCulture 和 Thread.CurrentThread.CurrentUICulture 在 App/ASP.NET 页面中设置当前线程的区域设置。
要为整个应用程序进行此设置,您可以在 web.config 中执行以下操作:
Sounds like the locale is being set correctly on one server but not the other.
There are a few ways you could do this, but you might want to set the locale for the current thread in your App/ASP.NET page using Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture.
To set this for the entire application, you'd do this in your web.config:
使用
我在您不希望有特定于文化的输出的情况下 。 (例如,当您为其他应用程序编写序列化数据等时)这样,无论当前设置什么文化,输出都将始终相同。
I use
in those cases where you do not want to have culture specific output. (For example, when you write serialize data for other applications etc.) This way no matter what Culture is currently set, the output will always be the same.