cultureinfo

Compact Framework - Retrieve a list of countries and regions

橙三吉。 提交于 2019-12-05 18:30:51
Afternoon people! I'm trying to implement a list of counties on my Compact Framework (Mobile) application. I can do this easily in the full .Net framework with CultureInfo.GetCultures(..etc). However, the CF seems to be missing this feature? Is there any way I can return a list of countries (and regions if possible) that I can populate into a ComboBox? The OS has a list of countries, so there must be a way to do it? I look forward to hearing back! How about this? using System; using System.Collections.Generic; using System.Globalization; using System.Runtime.InteropServices; namespace

Entity Framework - SQL Server 2005 - IIS Server datetime issue

核能气质少年 提交于 2019-12-05 17:55:30
I'm working with MVC3 and Entity Framework. In my application I need to call a stored procedure in SQL Server 2005 via EF to search for some data according to datetime parameters passed. Everything seems to be working fine in local environment. But after hosting it into IIS I am getting an exception while trying to search from date 13-08-2012 (13 is taking as month in SQL I guess) Error says SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM I understood error is because of the difference between date time formats between System.Datetime and SqlDatetime . But

Culture-Invariant case-sensitive string comparison returns different results on different machines

Deadly 提交于 2019-12-05 13:18:20
问题 I've found that the test results are different on my machine and the build server. I've managed to find the single line that differs. This is a string comparison. The two strings differ in case of the first character. The test below passes on my local machine and fails on the build machine. [TestClass] public class Tests { [TestMethod] public void Strings() { Assert.IsFalse(0 == string.Compare("Term’s", "term’s", false, CultureInfo.InvariantCulture)); } } I've also tried to change it to

Country name to ISO 3166-2 code

烈酒焚心 提交于 2019-12-05 06:48:49
I know how to convert an ISO 3166-2 code to the full English name, e.g. "US" to "United States" by using RegionInfo . However, how can I do the opposite, i.e. that takes "United States" and returns "US"? //Get the cultureinfo RegionInfo rInfo = new RegionInfo("us"); string s = rInfo.EnglishName; //Convert it back CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures); CultureInfo cInfo = cultures.FirstOrDefault(culture => new RegionInfo(culture.LCID).EnglishName == s); yesenin The main idea: take all region objects and select from them one which contains given full

Culture is not supported

醉酒当歌 提交于 2019-12-05 02:28:01
I'm using Visual Studio 2012 Ultimate version. I've got this error and I don't know how to solve it. Culture is not supported. Parameter name: name en-UK is an invalid culture identifier. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Globalization.CultureNotFoundException: Culture is not supported. Parameter name: name en-UK is an invalid culture identifier. please help me You should try en-GB for English (United

ASP.NET MVC (Async) CurrentCulture is not shared between Controller and View

删除回忆录丶 提交于 2019-12-05 01:31:22
I have an ASP.NET MVC 4 application that is targeting .NET Framework 4.7.1, with the problem that the culture is not shared between Controller and View, if the action contains async calls. I am referencing the NuGet package Microsoft.AspNet.Mvc 5.2.3 (and can be reproduced in 5.2.4). This is the code in the Controller: public class CulturesTestController : Controller { public async Task<ActionResult> Index(string value) { Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("fi-FI"); Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("fi-FI"); var model = new

changing cultureinfo on android using xamarin and c#

一个人想着一个人 提交于 2019-12-04 19:17:48
Im calling a custom method to dynamically switch the current cultureinfo to french "fr" Like this but after calling that method my android app still use the default culture which is 'en' but in debug mode the culture seems to be ok. My folder are ok. I have both and the string values are configured. folder: resource/values/strings.xml, resource/values-fr/strings.xml. Do I need to reload my contentview or something? what do I miss here? private void SetLocal(string lang) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(lang); System.Threading.Thread

Change culture when deserializing WCF service

隐身守侯 提交于 2019-12-04 19:05:00
I'm using C# to read data from a Java-webservice. I've created a Service reference in VS2008 to the server, and can call the one method that is there. However, a few of the fields returned are of type Decimal, and as the automatically generated WCF proxy gets XML back it fails with a CommunicationException saying: "Error in deserializing body of reply message for operation 'getOpenReceivables'." "There is an error in XML document (1, 941)." "Input string was not in a correct format." [Edit] Here is a full stacktrace: at System.Number.StringToNumber(String str, NumberStyles options,

C# format as currency with no trailing zero decimal numbers, consider negative, and different culture

☆樱花仙子☆ 提交于 2019-12-04 18:31:37
How can we format a number to currency without trailing zero decimal numbers? Basically it should behave as the "C" format specifier but without trailing zeroes. Below are the test cases. value | en-US | fr-FR 1 | $1 | 1 € 1.0 | $1 | 1 € 1.1 | $1.1 | 1,1 € 1.10 | $1.1 | 1,1 € -1 | ($1) | -1 € -1.0 | ($1) | -1 € -1.1 | ($1.1) | -1,1 € 1000 | $1,000 | 1 000 € 1000.0 | $1,000 | 1 000 € Is there a way to achieve this behavior by leveraging the "C" format specifier? side note: I am continuing from this related wpf question but focusing on the formatting part and with more exhaustive test cases. I

What is the recommend way to create a custom culture and associated resource files for a specific Client?

ぐ巨炮叔叔 提交于 2019-12-04 16:11:50
问题 I have client that wants to specifiy their own version of localized content for a subset of my string resources. For simplicity here is basic example: Lets say I have 2 localized strings (showing english content) PageTitle="Hello World" PageDescription="This is a more wordy version of Hello World!" I wish to localize these so I have resource files. Strings.resx (contains my English string) Strings.fr-ca.resx (contains my French-Canadian strings) Strings.fr-ca-clientX.resx (contains my strings