cultureinfo

Missing Countries & locations from CultureInfo when trying to

痴心易碎 提交于 2019-12-19 08:04:36
问题 I need to localize an application and have noticed that several countries don't appear in the list of county codes associated to cultureInfo. One example is Cyprus, I assume there might be others. If i need to localize settings for Cyprus (or other missing ones) how would I rename my resource files that they would render the correct text and such? Thanks 回答1: When localizing to Cyprus, you would need to either localize to Greek (for the Greek part of the island), or to Turkish (for the

Find out the Date time format of string date in c#

江枫思渺然 提交于 2019-12-18 08:55:20
问题 I am making an application. The application uses date format such as "2012-11-21 15:22:35" . I already know that the format is "yyyy-MM-dd HH:mm:ss" . But how can I find programmatically the date & time format of an arbitrary input string? Is there any way to do this? 回答1: This might help you.. (in the array, add more formats to check) string[] formats = {"M/d/yyyy", "MM/dd/yyyy", "d/M/yyyy", "dd/MM/yyyy", "yyyy/M/d", "yyyy/MM/dd", "M-d-yyyy", "MM-dd-yyyy", "d-M-yyyy", "dd-MM-yyyy", "yyyy-M-d

How to convert culture specific double using TypeConverter?

南楼画角 提交于 2019-12-18 07:03:25
问题 I have a problem with the TypeConverter class. It works fine with CultureInvariant values but cannot convert specific cultures like English thousands separators. Below is a small test program that I cannot get to work. Here's the problem :) - ConvertFromString throws an exception with the following message "2,999.95 is not a valid value for Double." and with the inner exception "Input string was not in a correct format." . using System; using System.Globalization; using System.ComponentModel;

How to convert “12,4” to decimal en-Us culture

流过昼夜 提交于 2019-12-18 03:38:27
问题 I have a decimal value ("133,3") stored in string column in the database, in norway culture. after that user changed the regional setting to english-Us. when I convert "133,3" to decimal using CultureInfo.InvariantCulture, getting invalid value or error. is there any best way to handle this scenario in C# application? regards, Anand 回答1: Regardless of the system culture, if you specify CultureInfo.InvariantCulture you won't be able to parse "133,3" as a decimal to 133.3. The same is true for

How to receive event when user changes system's culture

£可爱£侵袭症+ 提交于 2019-12-17 16:35:41
问题 When my application run with a specified culture. Don't close the application, user changes system's culture, ex: change number decimal separator from "." to ",". How to my application can catch this event. Thanks. Notes: C# 2.0, Windows Form. 回答1: You can handle the SystemEvents.UserPreferenceChanged event: void SystemEvents.UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e) { // Regional settings have changed if (e.Category == UserPreferenceCategory.Locale) { ... } } 回答2

Change Language in C#

倖福魔咒の 提交于 2019-12-17 10:59:17
问题 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 回答1: 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

.NET (3.5) formats times using dots instead of colons as TimeSeparator for it-IT culture?

冷暖自知 提交于 2019-12-17 07:55:13
问题 According to Wikipedia (and confirmed in an answer by Dario Solera), in Italy they format times using colons: The 24-hour notation is used in writing with a colon as a separator. Example: 14:05. The minutes are written with two digits; the hour numbers can be written with or without leading zero. However, running the following code seems to output dots: using System.Globalization; Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT"); Thread.CurrentThread.CurrentUICulture = new

.NET (3.5) formats times using dots instead of colons as TimeSeparator for it-IT culture?

旧街凉风 提交于 2019-12-17 07:54:15
问题 According to Wikipedia (and confirmed in an answer by Dario Solera), in Italy they format times using colons: The 24-hour notation is used in writing with a colon as a separator. Example: 14:05. The minutes are written with two digits; the hour numbers can be written with or without leading zero. However, running the following code seems to output dots: using System.Globalization; Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT"); Thread.CurrentThread.CurrentUICulture = new

Find number of decimal places in decimal value regardless of culture

。_饼干妹妹 提交于 2019-12-17 02:10:14
问题 I'm wondering if there is a concise and accurate way to pull out the number of decimal places in a decimal value (as an int) that will be safe to use across different culture info? For example: 19.0 should return 1, 27.5999 should return 4, 19.12 should return 2, etc. I wrote a query that did a string split on a period to find decimal places: int priceDecimalPlaces = price.ToString().Split('.').Count() > 1 ? price.ToString().Split('.').ToList().ElementAt(1).Length : 0; But it occurs to me

allow accented characters to be searchable? [duplicate]

99封情书 提交于 2019-12-14 01:54:30
问题 This question already has answers here : Closed 7 years ago . SOLVED: I used the following code: var compareinfo = CultureInfo.CurrentCulture.CompareInfo; var index = compareinfo.IndexOf(strA, strB, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase); return index > -1; Possible Duplicate: Ignoring accented letters in string comparison I have a public Kiosk application where users use it to search for a place of interest. Say I have a shop name with the Café word. The kiosk only allows