cultureinfo

.NET Chinese CultureInfo “zh” does not exist?

懵懂的女人 提交于 2019-12-13 19:09:53
问题 I'm using .NET 3.5 and running the following code: var culture = new CultureInfo("zh"); // Throws ArgumentException I got the string "zh" from an xml:lang attribute. I don't understand why an exception is thrown, because for instance "de" (wich is parent for "de-DE") is working fine. The culture "zh-CN" does work, but thats nothing that I can use. Edit: It works on .NET 4.5.1 (thanks to xanatos) - so even if the MSDN page explains that Chinese is an exception, the behaviour is different in

Are read-only CultureInfo objects thread-safe?

只愿长相守 提交于 2019-12-13 07:37:18
问题 Preface: I know how to create a read-only CultureInfo object. That is not the question and it has been answered in detail here: CultureInfo thread safety Note that the text of that question is similar to this one, but the answers are completely different. Before thinking about closing this question as a duplicate of the other one, please consider the fact that none of the answers in the other question answers this question. My question: Is it thread-safe to access instance members of a read

Machine Culture and DateTime

丶灬走出姿态 提交于 2019-12-13 07:27:50
问题 We set up a server wit the en-US culture by mistake. Later I changed the regional settings, the locale, and the IIS globalisation to en-GB. However, I'm having a problem with a Windows service I've written. It's still using the US format whenever DateTime.ToString() is done. I know I can specify the culture I want the string to be in, but I don't want to change all my code. It should just use the UK format because it's changed everywhere in the machine settings. Maybe there's a setting I've

EPPlus converting csv and missing the comma from a double

帅比萌擦擦* 提交于 2019-12-13 02:37:19
问题 I'm trying to convert a CSV file to xlsx file using the following code: string csvFileName = path; string nomeArquivo = Path.Combine(serverpath, RandomString(10) + ".xlsx"); string worksheetsName = "b2w"; bool firstRowIsHeader = false; var format = new ExcelTextFormat(); format.Delimiter = ';'; format.EOL = "\n"; // DEFAULT IS "\r\n"; // format.TextQualifier = '"'; using (ExcelPackage package = new ExcelPackage(new FileInfo(nomeArquivo))) { ExcelWorksheet worksheet = package.Workbook

Change the Currency Symbol thoroughout the Application

一个人想着一个人 提交于 2019-12-12 17:13:31
问题 I derive the controllers from a base class: namespace merawi.Controllers { public class BaseController : Controller { public CultureInfo trTR = new CultureInfo("tr-TR"); public BaseController() { trTR.NumberFormat.CurrencySymbol = "TL"; } } } and use this statement to format the currencies: ViewBag.SellingPrice = sp.ToString("C", trTR); However, in the views which has viewmodels like @model List<merawi.Models.DocumentWorkStep> I need a way to format the currencies as desired. SellingPrice is

Culture specific DateTime string is inconsistent between platforms

岁酱吖の 提交于 2019-12-12 15:23:17
问题 I have a test application that allows the user to select a culture from a ComboBox and displays the culture specific date in a multiline TextBox. The code is below: public partial class Form1 : Form { public Form1() { InitializeComponent(); comboBox1.Items.AddRange( CultureInfo.GetCultures(CultureTypes.SpecificCultures)); } private void comboBox1_SelectedValueChanged(object sender, EventArgs e) { CultureInfo selectedCulture = comboBox1.SelectedItem as CultureInfo; DateTime currentDate =

WPF double valued data binding with custom decimal separator

最后都变了- 提交于 2019-12-12 12:32:11
问题 Is there a centralized way to have the WPF UI to respect the customized decimal separator set in Control Panel -> Regional Settings? When I bind a double valued data to a text box, I want to enter the value using the decimal separator set in Regional settings. The code below (when put in App's ctor) will use the decimal separator of the current culture settings, but will not respect the customized decimal separator setting. I was hoping that this code could somehow easily be exteded to cover

C# and Current Local time for different countries

做~自己de王妃 提交于 2019-12-12 08:41:30
问题 C# offers a way to get the current date by DateTime.Now . But the problem is my server is on US and I get the US time when I use DateTime.Now Is there any way to get the current local time for a specific country in C# as my users are from around the world? (I have locale of each user, so if I Can get the current time for each locale then I’m safe) I've seen a way using Time Zone but then I have to keep time zone vs country reference. I’ve searched and most of the question here is about

CultureInfo issue with Modelbinding double in asp.net-mvc(2)

自作多情 提交于 2019-12-12 08:08:09
问题 In my Jquery script I post two doubles using the browser's CultureInfo (en-UK) that uses the . as a fraction separator. My MVC app is running on a server with locale nl-BE using the , as a fraction separator. [AcceptVerbs(HttpVerbs.Post)] public JsonResult GetGridCell(double longitude, double latitude) { var cell = new GridCellViewModel { X = (int)Math.Round(longitude, 0), Y = (int)Math.Round(latitude, 0) }; return Json(cell); } The modelbinding fails because of the parsing issue. I think it

C# parsing to datetime regardless of culture info

£可爱£侵袭症+ 提交于 2019-12-12 03:52:52
问题 I have problem parsing some date string where language is not english. The sample date string is "8 avril 2016 vendredi" which is "8 april 2016 friday" in english. I have tried this but no luck. DateTime dateTime; DateTime.TryParse("8 avril 2016 vendredi", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime); In my case, date string can be in any language so I cannot specify the culture in parsing. I appreciate your help. Thanks. 回答1: Behold, the terrible any parser! CultureInfo