- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
qr code c# mvc Globalization in Visual C#
16 Draw QR Code JIS X 0510 In Visual C# Using Barcode encoder for .NET framework Control to generate, create QR Code image in .NET framework applications. www.OnBarcode.comQR Code JIS X 0510 Reader In C#.NET Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications. www.OnBarcode.comGlobalization
Bar Code Printer In Visual C#.NET Using Barcode generator for .NET Control to generate, create bar code image in Visual Studio .NET applications. www.OnBarcode.comBarcode Decoder In C# Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comThe DateTimeFormatInfo class provides a comprehensive set of methods and properties to handle and respond to the dates of different cultures. Examine the following code: Denso QR Bar Code Generator In Visual Studio .NET Using Barcode creator for ASP.NET Control to generate, create QR Code image in ASP.NET applications. www.OnBarcode.comEncode QR Code JIS X 0510 In .NET Using Barcode drawer for .NET Control to generate, create QR image in Visual Studio .NET applications. www.OnBarcode.com' VB Dim UsersCulture As CultureInfo = New CultureInfo("es-VE") Dim Days() As String = UsersCulture.DateTimeFormat.DayNames For Each Day As String In Days Console.WriteLine("Day Name for Venezuelan Spanish : " & Day) Next // C# CultureInfo UsersCulture = new CultureInfo("es-VE"); String[] Days = UsersCulture.DateTimeFormat.DayNames; foreach (String Day in Days) { Console.WriteLine("Day Name for Venezuelan Spanish : " + Day); } Print Quick Response Code In VB.NET Using Barcode generator for .NET Control to generate, create QR-Code image in Visual Studio .NET applications. www.OnBarcode.comBarcode Generator In Visual C# Using Barcode generation for .NET Control to generate, create bar code image in Visual Studio .NET applications. www.OnBarcode.comThe corresponding output should resemble that shown in Figure 16-4. EAN / UCC - 14 Creation In Visual C#.NET Using Barcode encoder for .NET Control to generate, create UCC - 12 image in .NET applications. www.OnBarcode.comEncode EAN / UCC - 13 In C#.NET Using Barcode drawer for .NET framework Control to generate, create EAN13 image in .NET framework applications. www.OnBarcode.comFigure 16-4 USS Code 39 Printer In Visual C#.NET Using Barcode printer for .NET framework Control to generate, create Code 3/9 image in .NET framework applications. www.OnBarcode.comISSN - 13 Encoder In C# Using Barcode creator for VS .NET Control to generate, create ISSN image in VS .NET applications. www.OnBarcode.comEach day of the week in Venezuelan Spanish
Code 128A Encoder In Java Using Barcode encoder for Android Control to generate, create Code 128 Code Set A image in Android applications. www.OnBarcode.comEAN13 Maker In None Using Barcode creation for Office Word Control to generate, create UPC - 13 image in Office Word applications. www.OnBarcode.comIf this same code was run with United States English as the CurrentCulture, the output would be Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday, respectively. The same differences exist with respect to months, as shown in the following code: Bar Code Encoder In .NET Framework Using Barcode drawer for Reporting Service Control to generate, create barcode image in Reporting Service applications. www.OnBarcode.comGenerate Bar Code In Objective-C Using Barcode creator for iPhone Control to generate, create bar code image in iPhone applications. www.OnBarcode.com' VB Dim UsersCulture As CultureInfo = New CultureInfo("es-VE") Dim Months() As String = UsersCulture.DateTimeFormat.MonthNames For Each Month As String In Months Console.WriteLine("Month Name for Venezuelan Spanish : " & Month) Next Encoding Bar Code In Java Using Barcode printer for Java Control to generate, create bar code image in Java applications. www.OnBarcode.comEAN-13 Supplement 5 Generator In .NET Using Barcode creation for ASP.NET Control to generate, create European Article Number 13 image in ASP.NET applications. www.OnBarcode.comLesson 1: Using Culture Information
PDF 417 Generation In Java Using Barcode generation for Java Control to generate, create PDF417 image in Java applications. www.OnBarcode.comPainting Code 128 In None Using Barcode maker for Font Control to generate, create Code 128 Code Set B image in Font applications. www.OnBarcode.com// C# CultureInfo UsersCulture = new CultureInfo("es-VE"); String[] Months = UsersCulture.DateTimeFormat.MonthNames; foreach (String Month in Months) { Console.WriteLine("Month Name for Venezuelan Spanish : " + Month); } Again, when this code is run, the name of each month in Venezuelan Spanish will be shown. There are many other properties corresponding to just about every conceivable facet of date manipulation. One of the reasons this is so important is because of evaluation and comparisons. If one culture has a date format in mm/dd/yyyy format and the other stores the values in dd/mm/yyyy format, what would happen if you tried to compare them Chances are that you d end up with erroneous comparisons. However, by specifying that the dates are from different cultures, comparisons will work correctly. The same problem exists when dealing with numbers and currency, and essentially the same solution is in place using the NumberFormatInfo class instead of the DateFormatInfo class. This can be easily illustrated by using the same code we used previously, but with a slight modification: ' VB Dim UsersCulture As CultureInfo = New CultureInfo("es-VE") Console.WriteLine("Venezuelan Currency Symbol: " _ + UsersCulture.NumberFormat.CurrencySymbol) Console.WriteLine("Number Decimal Symbol: " _ + UsersCulture.NumberFormat.NumberDecimalSeparator) // C# CultureInfo UsersCulture = new CultureInfo("es-VE"); Console.WriteLine("Venezuelan Currency Symbol: " + UsersCulture.NumberFormat.CurrencySymbol); Console.WriteLine("Number Decimal Symbol: " + UsersCulture.NumberFormat.NumberDecimalSeparator); As shown by the output from this code, the Venezuelan currency abbreviation is Bs and a comma is used as the decimal separator when writing numbers. Using the CompareInfo Class and CompareOptions Enumeration for Culturally Aware Comparisons
One important reason to use the CultureInfo class is to allow for culturally aware string comparisons. To do this, the CultureInfo class has a CompareInfo property, which is an instance of the CompareInfo class. You can create a new instance of the CompareInfo class or, more practically, you can set it to the CompareInfo property of the CurrentCulture. 16
Globalization
The following code shows the results from outputting the current CompareInfo associated with the CurrentCulture on your machine: ' VB Dim DemoInfo As CompareInfo = _ Thread.CurrentThread.CurrentCulture.CompareInfo Console.WriteLine(DemoInfo.Name) Console.WriteLine(DemoInfo.LCID) // C# CompareInfo DemoInfo = Thread.CurrentThread.CurrentCulture.CompareInfo; Console.WriteLine(DemoInfo.Name); Console.WriteLine(DemoInfo.LCID); Comparisons are typically based on one specific culture. (For instance, if an application was written in the United States, all comparisons would probably be based on en-US.) Because of this, it s generally best to create a CompareInfo object based on the current culture. If necessary, however, you can also create a new CultureInfo object based on any culture you d like, as shown in the following code: ' VB Dim DemoInfo As CompareInfo = New CultureInfo("en-US").CompareInfo Console.WriteLine(DemoInfo.Name) Console.WriteLine(DemoInfo.LCID) // C# CompareInfo DemoInfo = Thread.CurrentThread.CurrentCulture.CompareInfo; Console.WriteLine(DemoInfo.Name); Console.WriteLine(DemoInfo.LCID); The most basic approach to using the CompareInfo class is to call the Compare method, passing in the values to be compared. The following code illustrates comparing two words for equivalency using the Compare method of the CompareInfo class: ' VB Dim FirstString = "Cot " Dim SecondString = "cot " Dim DemoInfo As CompareInfo = New CultureInfo("fr-FR").CompareInfo DemoInfo.Compare(FirstString, SecondString) // C# String FirstString = "Cot "; String SecondString = "cot "; CompareInfo DemoInfo = new CultureInfo("fr-FR").CompareInfo; DemoInfo.Compare(FirstString, SecondString); If you run this code, the two strings will not be considered equal. Even though the cultural information will evaluate to true, the casing is different. To handle items like this, you can use members of the CompareOptions enumeration to control how
|
|