globalization

String format currency

醉酒当歌 提交于 2019-11-26 04:24:49
问题 I have this line @String.Format(\"{0:C}\", @price) in my razor view. I want it to display a dollar sign in front of the price but instead it display a pound sign. How do I achieve this? 回答1: I strongly suspect the problem is simply that the current culture of the thread handling the request isn't set appropriately. You can either set it for the whole request, or specify the culture while formatting. Either way, I would suggest not use string.Format with a composite format unless you really

How to convert string to double with proper cultureinfo

Deadly 提交于 2019-11-26 03:40:19
问题 I have two nvarchar fields in a database to store the DataType and DefaultValue, and I have a DataType Double and value as 65.89875 in English format. Now I want the user to see the value as per the selected browser language format (65.89875 in English should be displayed as 65,89875 in German). Now if the user edits from German format to 65,89875 which is 65.89875 equivalent in English, and the other user views from an English browser it comes as 6589875. This happens because in the database

How to localize ASP.NET MVC application?

自古美人都是妖i 提交于 2019-11-26 03:29:15
问题 What would be best practice to localize your ASP.NET MVC application? I would like to cover two situations: one application deployment in IIS which would handle multiple languages one language/application deployment. In first situation should you go with some kind of view based thing like, ~/View/EN, ~/View/FI, ~/View/SWE or something different? What about second case, just application based config via Web.config and point these different languages to different URLs? 回答1: You can also take a

Regular expression for validating names and surnames?

眉间皱痕 提交于 2019-11-26 02:09:17
问题 Although this seems like a trivial question, I am quite sure it is not :) I need to validate names and surnames of people from all over the world. Imagine a huge list of miilions of names and surnames where I need to remove as well as possible any cruft I identify. How can I do that with a regular expression? If it were only English ones I think that this would cut it: ^[a-z -\']+$ However, I need to support also these cases: other punctuation symbols as they might be used in different

What is the difference between CurrentCulture and CurrentUICulture properties of CultureInfo in .NET?

☆樱花仙子☆ 提交于 2019-11-26 01:46:34
问题 In .NET there is the CultureInfo class in the System.Globalization namespace. It has two similar properties both returning values of the CultureInfo type: CurrentCulture and CurrentUICulture . What is the difference between them? Which one should I use when and why? 回答1: CurrentCulture is the .NET representation of the default user locale of the system. This controls default number and date formatting and the like. CurrentUICulture refers to the default user interface language, a setting

how do I set the default locale for my JVM?

假如想象 提交于 2019-11-26 01:27:47
问题 I want to set the default Locale for my JVM to fr_CA. What are the possible options to do this? I know of only one option Locale.setDefault() 回答1: From the Oracle Reference: The default locale of your application is determined in three ways. First, unless you have explicitly changed the default, the Locale.getDefault() method returns the locale that was initially determined by the Java Virtual Machine (JVM) when it first loaded. That is, the JVM determines the default locale from the host

How can I detect the encoding/codepage of a text file

元气小坏坏 提交于 2019-11-25 22:57:11
问题 In our application, we receive text files ( .txt , .csv , etc.) from diverse sources. When reading, these files sometimes contain garbage, because the files where created in a different/unknown codepage. Is there a way to (automatically) detect the codepage of a text file? The detectEncodingFromByteOrderMarks , on the StreamReader constructor, works for UTF8 and other unicode marked files, but I\'m looking for a way to detect code pages, like ibm850 , windows1252 . Thanks for your answers,

What is the difference between CurrentCulture and CurrentUICulture properties of CultureInfo in .NET?

狂风中的少年 提交于 2019-11-25 20:18:56
In .NET there is the CultureInfo class in the System.Globalization namespace. It has two similar properties both returning values of the CultureInfo type: CurrentCulture and CurrentUICulture . What is the difference between them? Which one should I use when and why? Tomalak CurrentCulture is the .NET representation of the default user locale of the system. This controls default number and date formatting and the like. CurrentUICulture refers to the default user interface language, a setting introduced in Windows 2000. This is primarily regarding the UI localization/translation part of your app