货币本地化问题 [英] Currency Localization Issue
问题描述
好的,我有一个数据库表,它有产品价格,如下:
ProductPrice MONEY
ProductIsoCurrencyCode CHAR(3)
现在,CultureInfo和RegionInfo都有
里面的货币处理功能,但是我希望在给定信息的情况下在我的网站上显示价格>
以上,加上网站访客的当前文化。
所以,我有
- 价值(例如23834.23)>
- IsoCurrencyCode(例如EUR)
- CultureCode(zh-CN)
如何组合上面的3以获得正确的格式我用bb来存储CurrencyFormat在数据库中的字符串,直到我意识到许多欧元国家以不同的方式格式化欧元并且我显示它们中的几个非常错误地显示它。
例如:
- 爱尔兰:a ?? 12.34
- 法国和西班牙:12,34a ?? (也是法国的12a ?? 34)
- 德国和意大利:a ?? 12,34
鲍里斯叶利钦
OK, I have a database table, it has prices of products in it, like so:
ProductPrice MONEY
ProductIsoCurrencyCode CHAR(3)
Now, both CultureInfo and RegionInfo have currency-handling functions inside
them, but I want to display the price on my web site given the information
above, plus the current culture of the web site visitor.
So, I have
- Value (e.g. 23834.23)
- IsoCurrencyCode (e.g. EUR)
- CultureCode (en-GB)
How do I combine the 3 above to get the correct formatting?
I used to store a "CurrencyFormat" string in the database, until I realised
that a lot of the Euro countries format the Euro differently and I was
displaying it quite incorrectly for several of them.
For instance:
- Ireland: a??12.34
- France and Spain: 12,34a?? (also 12a??34 in France)
- Germany and Italy: a??12,34
Thanks,
The Boris Yeltsin
推荐答案
嗨鲍里斯,
十进制d = 23834.23m;
string money = d.ToString(c,CultureInfo.CreateSpecificCulture(" en-GB")。NumberFormat);
将en-GB替换为您选择的文化。< br $>
-
快乐的编码!
Morten Wennevik [C#MVP]
Hi Boris,
decimal d = 23834.23m;
string money = d.ToString(c, CultureInfo.CreateSpecificCulture("en-GB").NumberFormat);
Replace en-GB with culture of your choice.
--
Happy coding!
Morten Wennevik [C# MVP]
" Morten Wennevik" < Mo ************ @ hotmail.comwrote in
news:op.tdpwcrrnklbvpo@stone:
"Morten Wennevik" <Mo************@hotmail.comwrote in
news:op.tdpwcrrnklbvpo@stone:
嗨Boris,
十进制d = 23834.23m;
string money = d.ToString(c,CultureInfo.CreateSpecificCulture(" en-
Hi Boris,
decimal d = 23834.23m;
string money = d.ToString(c, CultureInfo.CreateSpecificCulture("en-
GB")。NumberFormat);
GB").NumberFormat);
>
将en-GB替换为您选择的文化。
>
Replace en-GB with culture of your choice.
请忽略此建议。货币不是数字+某个符号。
即使在美国,-23834.23也是-23,834.23。作为数字但是(
Please ignore this advice. A currency is not a number + some symbol.
Even in US, -23834.23 is "-23,834.23" as a number but "(
23,834.23)作为
货币(注意减去vs括号)
对于Win32 API,请看这里: http://www.mihai-nita.net/20050709a.shtml
我知道这不是什么你需要,我在.NET中寻找正确的东西,
只是想阻止你走这条路:-)
-
Mihai Nita [微软MVP,Windows - SDK]
http:// www .mihai-nita.net
-------------------------------- ----------
将_year_替换为_以获取真实的电子邮件
23,834.23)" as
currency (note minus vs brackets)
For Win32 API, see here: http://www.mihai-nita.net/20050709a.shtml
I know this is not what you need, I am looking for the right thing in .NET,
just wanted to stop you from going ahead that route :-)
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
这篇关于货币本地化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!