The reason that the maximum is 84 characters is because that is what the CultureAndRegionInfoBuilder class restricts the length to. But you can't just declare a culture called "ThisIsLongerThan8Characters" because you must seperate the culture name with - (or _ it seems) with each part being a maximum of 8 characters long.
The following code creates a culture with a length of 84 characters, registers it, uses it and unregisters it.
string cultureName = "qwertyui-12345678-qwertyui-12345678-qwertyui-12345678-qwertyui-12345678-qwertyui-123";
Console.WriteLine( "MAX LENGTH: " + cultureName.Length );
try {
CultureAndRegionInfoBuilder.Unregister( cultureName );
} catch {
Console.WriteLine( "Cannot remove culture" );
}
CultureAndRegionInfoBuilder builder = new CultureAndRegionInfoBuilder( cultureName , CultureAndRegionModifiers.None );
CultureInfo ci = new CultureInfo( "en-AU" );
RegionInfo ri = new RegionInfo( "US" );
builder.LoadDataFromCultureInfo( ci );
builder.LoadDataFromRegionInfo( ri );
builder.Register();
CultureInfo info = new CultureInfo( cultureName );
Console.WriteLine( DateTime.Now.ToString( info.DateTimeFormat.LongDatePattern ) );
Console.WriteLine( info.Name );
Console.WriteLine( info.DisplayName );
try {
CultureAndRegionInfoBuilder.Unregister( cultureName );
} catch {
Console.WriteLine( "Cannot remove culture" );
}
No comments:
Post a Comment