CultureInfo.GetCultures(CultureTypes.SpecificCultures)
CultureInfo ci = new CultureInfo(string s);
Then you have things like
ci.DisplayName
ci.EnglishName
ci.DateTimeFormat.DayNames
For calendar information, you have
ci.Calendar.GetYear(DateTime.Today)
There is more information on calendars in the exercises
at the end of the chapter.
DateTimeFormatInfo dtfi = ci.DateTimeFormat;
Calendar ci = ci.Calendar;
DateTime dt = DateTime.Today;
cal.GetType().ToString(); //type of calendar
cal.GetDayOFMonth(dt)); //today, in local format
cal.GetMonth(dt));
cal.GetYear(dt));
cal.GetDayOfWeek(dt));
cal.GetMonthsInYear(cal.GetYear(dt));
And there are a lot of methods for handling time in the local
format, such as
AddDays()
AddHours() ....
GetDaysInMonth()
GetEra()
IsLeapDay()
IsLeapMonth() ....
ToFourDigitYear()
And there are subclasses of
Calendar,
such as
GregorianCalendar.
For currency,
ci.NumberFormat.CurrencySymbol
Also at the end of the chapter is how to retrieve information
on Region:
RegionInfo rgi = new RegionInfo(someRegion);
rgi.Name;
rgi.DisplayName;
rgi.EnglishName;
rgi.CurrencySymbol;
For the name of the current local region,
(Kalani, pages 633, box)
Thread.CurrentThread.CurrentRegion
Thread.CurrentThread.CurrentCulture =
new CultureInfo(string selectedCulture);
CultureInfo ciInv = new CultureInfo("");
CultureInfo ciInv = CultureInfo.InvariantCulture;
ResourceManager rem = new ResourceManager(
"mySolution.myResourceFile",
Type,GetType("myProject.mySolution").Assembly);
lblSomething.Text = rm.GetString("Something");
etc., etc., etc., etc.
<?xml version="1.0" encoding="UTF-8"?>
this.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
const int WS_EX_LAYOUTRTL = 0x400000;
const int WS_EX_NOINHERITLAYOUT = 0x100000;
protected override CreateParams CreateParams
{
get
{
CreateParams CP = base.CreateParams;
if (! base.DesignMode)
CP.ExStyle = CP.ExStyle | WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT;
return CP;
}
}
This reverses the Form itself, it even seems to reverse text boxes
and buttons, even though their "Right to Left"
property isn't set either to
RightToLeft.Yes or to
RightToLeft.Inherit.
And there are odd results. The text strings are not
reversed, though they are right-adjusted,
and punctuation appears where you don't expect it.
There is a list of the effects of the "RightToLeft"
setting on each control in Dr. International.
(Dr. International, pp. 299-306)
TextElementEnumerator iter =
StringInfo.GetTextElementEnumerator(myStringWithLongChars);
iter.MoveNext();
do
{
// now can use iter.ElementIndex
// and iter.Current
}
while (iter.MoveNext());
int compareResult =
String.Compare(string1, string2, false, CultureInfo.CurrentCulture);
public static void Sort(Array, IComparer);
because it is only in the description of
IComparer that I can find
something like "Comparison procedures use the
Thread.CurrentCulture of the current thread
unless otherwise specified.
String comparisons might have different results depending
on the culture."
// Creates a SortKey using the en-US culture.
CompareInfo myComp_enUS =
new CultureInfo("en-US",false).CompareInfo;
SortKey mySK1 = myComp_enUS.GetSortKey( "llama" );
For more about sorting llamas
(oh, sometimes they're equal,
and sometimes they're not equal),
see the on-line Help.