cultureinfo

Replace German characters (umlauts, accents) with english equivalents

旧城冷巷雨未停 提交于 2019-11-28 00:49:32
Replace German characters (umlauts, accents) with english equivalents I need to remove any german specific characters from various fields of text for processing into another system which wont accept them as valid. So the characters I am aware of are: ß ä ö ü Ä Ö Ü At the moment I have a bit of a manual way of replacing them: myGermanString.Replace("ä","a").Replace("ö","o").Replace("ü","u")..... But I was hoping there was a simpler / more efficient way of doing it. Since I'll be doing it on thousands of strings per run, 99% of which will not contain these chars. Maybe a method involving some

Async call to the WCF service doesn't preserve CurrentCulture

爱⌒轻易说出口 提交于 2019-11-28 00:11:12
According to the answer in this question async/await call should preserve CurrentCulture. In my case, when I call my own async methods, the CurrentCulture is preserved. But if I call some method of WCF service, CurrentCulture isn't preserved, it's being changed to something that looks like server's default thread's culture. I've looked at what managed threads are invoked. It happens so that every line of code was executed on a single managed thread (ManagedThreadId stays the same). And CultureInfo stays the same after a call to my own async method. But when I call a WCF's method,

String.Format not converting integers correctly in arabic

蓝咒 提交于 2019-11-27 23:09:22
I have a problem with String.Format. The following code formats the string correctly apart from the first integer. Current culture is set to Iraqi arabic (ar-IQ): int currentItem= 1; string of= "من"; int count = 2; string formatted = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", currentItem, of, count); The text is formatted right to left and the 2 is converted to an arabic digit, but the 1 isn't. Any ideas? The default behaviour for converting numeric values is "Context", which basically means if a number is proceeded by Arabic they display in Arabic (or another "non-Latin" character

CultureInfo & DateTimeInfo: How to check if is 24 hour time?

六眼飞鱼酱① 提交于 2019-11-27 22:14:25
问题 I'm modifying a globalized web application which uses stored CultureInfo for each logged in user. The client would like time data entry to be localized. Displaying is not a problem as the formatting is already available. However I need to detect if the current cultureinfo is for 24 hour time or am/pm so I can display the correct input boxes (not just a textfield). My initial idea was to check the DateTimeInfo property of CultureInfo and see if the ShortTimePattern contained a capital H or a

Get current language in CultureInfo

泪湿孤枕 提交于 2019-11-27 21:47:32
How to identify the operating system's language using CultureInfo ? E.g. if the language in Windows is set to French, I need to identify French and load the fr resource files data. I think something like this would give you the current CultureInfo: CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; Is that what you're looking for? This is what i used: var culture = System.Globalization.CultureInfo.CurrentCulture; and it's working :) Current system language is retrieved using : CultureInfo.InstalledUICulture "Gets the CultureInfo that represents the culture installed with the

DateTime and CultureInfo

雨燕双飞 提交于 2019-11-27 20:38:21
I have this in my code: var date1 = DateTime.ParseExact(date, "dd.MM.yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); And when my current cultur is dutch ( nl-NL ) instead of May 1st I get January 5th. I think the error is in the second parameter dd.MM.yyyy HH:mm:ss . Is there a way to fix this using the CultureInfo class? MMK You may try the following: System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("nl-NL"); DateTime dt = DateTime.Parse(date, cultureinfo); Use CultureInfo class to change your culture info. var dutchCultureInfo =

Format string by CultureInfo

不打扰是莪最后的温柔 提交于 2019-11-27 20:01:19
I want to show pound sign and the format 0.00 i.e £45.00, £4.10 . I am using the following statement: <td style="text-align:center"><%# Convert.ToString(Convert.ToSingle(Eval("tourOurPrice")) / Convert.ToInt32(Eval("noOfTickets")), new System.Globalization.CultureInfo("en-GB")) %></td> But it is not working. What is the problem. Can any one help me??? Use the Currency standard format string along with the string.Format method that takes a format provider: string.Format(new System.Globalization.CultureInfo("en-GB"), "{0:C}", amount) The CultureInfo can act as a format provider and will also get

What cultures are supported by the CultureInfo class in .NET 3.5?

回眸只為那壹抹淺笑 提交于 2019-11-27 19:29:16
问题 I need a list of cultures that are supported by .NET 3.5, regardless of the OS used. This seems to be quite a struggle to obtain, though I am not sure why! Edit: Arghh, I was not aware that it is dependent on the OS, that would explain the lack of documentation. Any ideas on what is supported by Mac/Linux OS as well? Thanks :) 回答1: Unfortunately, it is OS dependent. Check here for default language support per OS. Note, the CultureInfo documentation warns: Windows versions or service packs can

Change Language in C#

自闭症网瘾萝莉.ら 提交于 2019-11-27 14:05:40
I am developing a multilingual program in C# on Windows How to change Windows writing language on certain actions... e.g. to change from English to Arabic on focus event. Thanks Dr Herbie To select a whole new culture, set the CurrentThread.CurrentCulture to a new culture, e.g. to set to French: System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("fr-FR"); System.Threading.Thread.CurrentThread.CurrentCulture = ci; You can find a list of the predefined CultureInfo names here and here . If you want to change certain aspects of the default culture, you can grab the current

Could string comparisons really differ based on culture when the string is guaranteed not to change?

大城市里の小女人 提交于 2019-11-27 11:25:33
问题 I'm reading encrypted credentials/connection strings from a config file. Resharper tells me, "String.IndexOf(string) is culture-specific here" on this line: if (line.Contains("host=")) { _host = line.Substring(line.IndexOf( "host=") + "host=".Length, line.Length - "host=".Length); ...and so wants to change it to: if (line.Contains("host=")) { _host = line.Substring(line.IndexOf("host=", System.StringComparison.Ordinal) + "host=".Length, line.Length - "host=".Length); The value I'm reading