{"id":5972,"date":"2014-04-11T06:54:30","date_gmt":"2014-04-11T06:54:30","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/11\/problem-about-cultureinfo-collection-of-common-programming-errors\/"},"modified":"2014-04-11T06:54:30","modified_gmt":"2014-04-11T06:54:30","slug":"problem-about-cultureinfo-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/11\/problem-about-cultureinfo-collection-of-common-programming-errors\/","title":{"rendered":"problem about cultureinfo-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a46a4c908e34a772df9c61fb2bb99b3c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJimmy<br \/>\n.net datetime parsing cultureinfo<br \/>\nI have a string that looks like this: &#8220;9\/1\/2009&#8221;. I want to convert it to a DateTime object (using C#).This works:DateTime.Parse(&#8220;9\/1\/2009&#8221;, new CultureInfo(&#8220;en-US&#8221;));But I don&#8217;t understand why this doesn&#8217;t work:DateTime.ParseExact(&#8220;9\/1\/2009&#8221;, &#8220;M\/d\/yyyy&#8221;, null);There&#8217;s no word in the date (like &#8220;September&#8221;), and I know the specific format, so I&#8217;d rather use ParseExact (and I don&#8217;t see why CultureInfo would be needed). But I keep getting the dreaded &#8220;String was not recognized as a valid DateTime&#8221;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b6116ac3c4b5835c6745570ea73a85c1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nCharles<br \/>\nc# .net cultureinfo<br \/>\nI just ran into something very strange, and was just wondering if I was missing something.I was trying to parse a string (with thousand seperators) into a double, and found the below issue.CultureInfo ci = CultureInfo.CurrentCulture; \/\/ en-ZA string numberGroupSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator; \/\/numberGroupSeparator = , string numberDecimalSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;\/\/numberDecimalSeparator = . string strValu<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/78a0a4bb106d07b6c6f33a51988155e3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPeter Mortensen<br \/>\nc# internationalization globalization cultureinfo<br \/>\nCan somebody explain to me what is the use of globalization in C#?Is it used for conversion purposes? I mean I want to convert any English word into a selected language. So will this globalization or cultureinfo help me?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/tNrKk.jpg?s=32&amp;g=1\" \/><br \/>\nBetamoo<br \/>\nc# .net windows multilingual cultureinfo<br \/>\nI am developing a multilingual program in C# on WindowsHow to change Windows writing language on certain actions&#8230;e.g. to change from English to Arabic on focus event.Thanks<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b39da10df2442aa755d58bee68271911?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBkkGun<br \/>\n.net wpf assemblies cultureinfo<br \/>\nfrom http:\/\/msdn.microsoft.com\/en-us\/library\/sb6a8618(v=vs.80).aspx It seems like i need to have culture folder under the main executing assembly folder for example it will be &#8220;myprogram\/de\/&#8221;, &#8220;myprogram\/en\/&#8221; however, i&#8217;m wondering if i could do something like &#8220;myprogram\/resources\/de\/&#8221;, &#8220;myprogram\/resources\/en\/&#8221; so that i wont have a bunch of resource folders in the main project location<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0cac4b7ee828f27c08704b1bfc356b9e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMohammed A. Fadil<br \/>\nc# wpf visual-studio cultureinfo currentuiculture<br \/>\nWe are developing a localized English\/Arabic application, and I need to set the System.Threading.Thread.CurrentThread.CurrentUiCulture to either of both cultures during design time to a different value than the value set at run time.How can I accomplish this?Thanks in advance.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a6ca121bfa05b6a1d99a092817962fa9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nYoshieMaster<br \/>\nc# cultureinfo<br \/>\nI cannot use GetCultures, from what I can tell it returns a blank list.private void AddressChooser_Load(object sender, EventArgs e){MessageBox.Show(&#8220;Form load event successfully triggered&#8221;) \/\/Debug message &#8211; This appears at runtimeforeach (string country in GetCountryList()){MessageBox.Show(country); \/\/Debug message &#8211; This does not appear at runtime!!countryBox.Items.Clear();countryBox.Items.Add(country);}}public static List&lt;string&gt; GetCountryList(){MessageBox.Show(&#8220;Function has been trigg<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dc85d53dbf49b5ea7d887052063f1882?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser2042227<br \/>\nwindows-phone cultureinfo<br \/>\nIn windows phone how can I change between 2 cultures inside the app, for example when user clicks on language setting inside app, it should change between English and Arabic, based on the Appresource files I created?I have tried this on button click, but doesn&#8217;t work:Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(&#8220;ar-SA&#8221;);Thanx<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/72dadfbe69b47f92b37ee8aa92b91024?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTrBaPhong<br \/>\nc# cultureinfo<br \/>\nI create a simple window application with one buttonpublic partial class Form1 : Form {public Form1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){MessageBox.Show(CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol);} }First time I click &#8220;button 1&#8221;, it show &#8220;$&#8221; I open control panel &gt; Region and Language to change currency symbol from &#8220;$&#8221; to &#8220;?&#8221; Click &#8220;button 1&#8221; again, it also show &#8220;$&#8221; ==&gt; my expected result is &#8220;?&#8221;It seem that CultureInfo.CurrentCulture does no<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fd615875676c14ae31e7a8ac850b494b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nManoj Nayak<br \/>\nc# decode encode cultureinfo<br \/>\nI have a hiddenfield in which i am storing storing the user input and code generated value in string format. Since the string may contain the hyperlink etc i used HTmlEncode before putting it into a hidden field and used to decode the value when i am retrieving from the hiddenfield.If the user input contain French characters then the code will crash. How to encode a string containg- links,french and other culture characters.I am getting the below errorA potentially dangerous Request.Form value w<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/830bc0674c56e9314ab6801dc263ef4e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMaris<br \/>\nc# .net cultureinfo<br \/>\nI found one interesting thing in CultureInfo class. I was writting an app in ASP.NET and I was using Thread.CurrentThread.CurrentCulture to get the current selected language and:Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(alias);There was 2 places where I can set the culture of the current thread in one place I was doing like these:Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(&#8220;ru&#8221;); Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(&#8220;ru-RU&#8221;)<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0edf2e8809543f7a7411b39abfed16c3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGabriel Isenberg<br \/>\nasp.net globalization cultureinfo<br \/>\nI&#8217;m running into a case where an ASP.NET application using the built-in globalization facilities is crashing. On an ASP.NET page with the Culture=&#8221;auto&#8221; directive, a user with a neutral culture as their browser language (such as &#8220;zh-Hans&#8221;) will produce the following exception:Culture &#8216;zh-Hans&#8217; is a neutral culture. It cannot be used informatting and parsing and thereforecannot be set as the thread&#8217;s currentculture.at System.Globalization.CultureInfo.CheckNeutral(CultureInfoculture) at System.Thr<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8348bcf40f55bc5818651824369caff1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSoner G\u00f6n\u00fcl<br \/>\nc# asp.net cultureinfo<br \/>\nI&#8217;m using Visual Studio 2012 Ultimate version.I&#8217;ve got this error and I don&#8217;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 ofthe current web request. Please review the stack trace for moreinformation about the error and where it originated in the code. Exception Details: System.Globalization.CultureNotFoundException:Culture is not supported. Parameter name: name en-UK i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/ssAbQ.jpg?s=32&amp;g=1\" \/><br \/>\nClay Shannon<br \/>\nc# datetime cultureinfo<br \/>\nThis line of code:DateTime dt = DateTime.ParseExact(time, &#8220;hh:mm&#8221;, CultureInfo.InvariantCulture);parses a &#8220;time&#8221; value of &#8220;12:45&#8221; just fine, but throws an exception of &#8220;13:00&#8243;Should I be using some other CultureInfo value, or do I need to append a &#8220;pm&#8221; to hour values above 12, or &#8230; ?Error message is: System.FormatException was unhandledMessage=String was not recognized as a valid DateTime.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4ec905870f05ccb503cf38bdb9b0e2b8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSamuel Neff<br \/>\nc# .net datetime cultureinfo<br \/>\nWe have an application parsing date\/time values in the following format:2009-10-10 09:19:12.124 2009-10-10 12:13:14.852 2009-10-10 13:00:00 2009-10-10 15:23:32.022One particular server all of the sudden (today) started failing to parse any times 13:00:00 or later. This particular client has five servers and only one has the problem. We have dozens of other clients with a total of hundreds of servers without the problem.System.FormatException: String was not recognized as a valid DateTime. at S<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/graph.facebook.com\/631351428\/picture?type=large\" \/><br \/>\nAbhranil Das<br \/>\nc# .net cultureinfo indexof<br \/>\nI have string &#8220;\u00c4rger,-\u00d6konom-i-\u00dcbermut-?-\u00df&#8221; and when I run IndexOf(&#8220;&#8211;&#8220;) I get a result of 23. If I use Replace on same string nothing gets replaced.I don&#8217;t understand what is happening, so can someone please shed some light on this issue? Application Culture is set on Croatian, it&#8217;s not German, and framework version is 3.5.Changing culture to German (de-DE) doesn&#8217;t change this strange behavior.Here is the screenshot from the debugger:<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Jimmy .net datetime parsing cultureinfo I have a string that looks like this: &#8220;9\/1\/2009&#8221;. I want to convert it to a DateTime object (using C#).This works:DateTime.Parse(&#8220;9\/1\/2009&#8221;, new CultureInfo(&#8220;en-US&#8221;));But I don&#8217;t understand why this doesn&#8217;t work:DateTime.ParseExact(&#8220;9\/1\/2009&#8221;, &#8220;M\/d\/yyyy&#8221;, null);There&#8217;s no word in the date (like &#8220;September&#8221;), and I know the specific format, so I&#8217;d rather use ParseExact [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5972","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5972"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5972\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}