FAQ Database Discussion Community


Bootstrap DateTimePicker format

c#,asp.net-mvc-5,format,cultureinfo,bootstrap-datetimepicker
I am coding a MVC 5 internet application and am using the bootstrap-datetimepicker in a view. My application is being used internationally and I would like to format the datetimepicker to have the correct format for each user. I have the culture and the timezone for each user, how is...

Regional decimal seperator input [closed]

c#,decimal,cultureinfo,region
Computers in my country do not accept decimals with a '.' they only accept ',' How do I write a program which would accept 12.5 from the console as a decimal number?...

Use of CultureInfo.InvariantCulture

c#,decimal,cultureinfo
I'm working on a project that uses decimals in a textbox. I'm currently developing in a machine that has decimal separators set to "," instead of "." so I had to use this sentence when parsing text string into decimal: decimal number = Decimal.Parse(number.Text, CultureInfo.InvariantCulture); Now... Is CultureInfo.InvariantCulture the right...

Validate double number in current culture

c#,parsing,double,cultureinfo,currentculture
There is a way to validate a double number in the current culture? I have tried this: var number ="10,10"; double value = double.Parse(number, NumberStyles.Float, CultureInfo.CurrentCulture); If I try this with "es-ES" (where decimal separator is ",") then the parsing works perfect, I got an double 10.10, but if I...

Convert DateTime with a specified language

datetime,asp.net-mvc-5,utc,cultureinfo,localtime
I am coding a MVC 5 internet application and am wanting to convert a DateTime to be displayed as a LocalTime where I have the language. This is for an Azure website. Here is my code: DateTime dateTimeUtcNow = DateTime.UtcNow; DateTime convertedDate = DateTime.SpecifyKind(dateTimeUtcNow, DateTimeKind.Utc); DateTime dateTimeLocalTime = convertedDate.ToLocalTime(); return...

How to create a multilingual project

vb.net,localization,cultureinfo,resourcemanager
I'm new to VB.net and I'm trying to do a simple multilingual project. So far I've created 2 resource files: en-US.resx pt-PT.resx in both of them I have the same ID's and diferent values (strings only) (these strings will be used across multiple forms) When I change the laguage I...

Difficulties with CultureInfo and representation in Listbox

c#,sql,winforms,listbox,cultureinfo
I'm trying to represent the right double value in my Listbox. The values in my SQL Database are represented as "0,09" for example. Now I put these values which are in a certain column into a Listbox with a "SELECT DISTINCT" statement. When searching in the database I need to...

Why LCID is not unique?

c#,.net,cultureinfo,lcid
Why LCID is not unique? My code: var data = CultureInfo.GetCultures(CultureTypes.AllCultures) .OrderBy(n=>n.LCID).ToArray().GroupBy(s => s.LCID) .Where(n=>n.Count() > 1).SelectMany(m => m); I see two LCID is not unique: 4 and 31748. Therefore I can't use such code: Dictionary<Int32, CultureInfo> valid_lcids = CultureInfo.GetCultures(CultureTypes.AllCultures).ToDictionary( c => c.LCID, c => c); ...

ToLower vs ToLowerInvariant

c#,.net,localization,globalization,cultureinfo
I'm just looking for any example that this two methods produces different results. First of all, I visit msdn page, and run code from it with minor changes using System; using System.Globalization; using System.Linq; class Program { static void Main() { string[] words = { "Tuesday", "Salı", "Вторник", "Mardi", "Τρίτη",...

Regular expression to match German number

regex,formatting,cultureinfo
I am wondering, how would regular expression for testing correct format of number for German culture would look like. In German, comma is used as decimal mark and dot is used to separate thousands. Therefore: 1.000 equals to 1000 1,000 equals to 1 1.000,89 equals to 1000.89 1.000.123.456,89 equals to...

System.Globalization.RegionInfo complete list of valid culture inputs

c#,cultureinfo,iso,region
I've got a list of ISO 3166 two-letter country codes acquired from an external source. For each, I create new System.Globalization.RegionInfo(countryCode) and occasionally one is invalid resulting in an ArgumentException "Culture name 'xx' is not supported." I want a function to determine if the country code is valid before I...

German culture - get double number from JSON with a comma

c#,json,formatting,cultureinfo,culture
I have an MVC Web-API application for inner use. I have some pages with forms and numeric fields. I need to install this on a German computer, and the users will be only Germans. In Germany they write "3,5" instead of "3.5" (with a comma). In IIS configuration the culture...

Sorting and summation over a set of words gives incorrect result

c#,arrays,sorting,cultureinfo
I am having trouble with Project Euler's Problem 22 Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in...

Display current datetime depending on client [duplicate]

c#,azure,timezone,cultureinfo
This question already has an answer here: How to handle Azure's UTC Time 1 answer I am currently saving the datetime.utcnow in the database on azure but im not sure how to display the correct time depending on the client. Should I be using utc? Should I save the...

Is String culture info important for comparison if the user will never modify those strings

c#,string,string-comparison,cultureinfo,hardcode
When comparing hard-coded Strings that the User will see but not modify/change, is the culture info important. I would assume not, but I just want to be safe. Example: static void Main() { string hardString = "IAMHardCodei"; string hardString2 = "IamHardCodei"; //Compare hardString and hardString2, ignoring case, //and then do...

How can I check the validation of the LCID without try\catch block?

c#,.net,cultureinfo,lcid
Some types has the TryParse method, for example it is Int32, Int64, Boolean, etc. It allows check the string value without try\catch block. It very much influences on productivity when many incorrect values are processing in a cycle. I need to do the same for string value of the LCID....

ASP.NET webcontrols render wrong in different culture settings

asp.net,globalization,cultureinfo,asp.net-webcontrol,currentuiculture
I have a self defined web control. Some code in a loop: double cellHeight = 12.34; Label dcell = new Label(); dcell.Style["height"] = cellHeight + "pt"; dcell.Text = cellHeight; If I use CultureInfo("cs-CZ") System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("cs-CZ"); System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("cs-CZ"); after render, the html came out <span style="height:11,75pt">11,75</span> actually...