Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,25 +277,20 @@ public static CultureInfo CreateSpecificCulture(string name)
// When CultureInfo throws this exception, it may be because someone passed the form
// like "az-az" because it came out of an http accept lang. We should try a little
// parsing to perhaps fall back to "az" here and use *it* to create the neutral.
culture = null;
for (int idx = 0; idx < name.Length; idx++)
int idx = name.IndexOf('-');
Comment thread
stephentoub marked this conversation as resolved.
if (idx >= 0)
{
if ('-' == name[idx])
try
{
try
{
culture = new CultureInfo(name.Substring(0, idx));
break;
}
catch (ArgumentException)
{
// throw the original exception so the name in the string will be right
throw;
}
culture = new CultureInfo(name.Substring(0, idx));
}
catch (ArgumentException)
{
// throw the original exception so the name in the string will be right
throw;
}
}

if (culture == null)
else
{
// nothing to save here; throw the original exception
throw;
Expand Down Expand Up @@ -1150,7 +1145,7 @@ private static Dictionary<int, CultureInfo> CachedCulturesByLcid
public static CultureInfo GetCultureInfoByIetfLanguageTag(string name)
{
// Disallow old zh-CHT/zh-CHS names
if (name == "zh-CHT" || name == "zh-CHS")
if (name is "zh-CHT" or "zh-CHS")
{
Comment thread
stephentoub marked this conversation as resolved.
throw new CultureNotFoundException(nameof(name), SR.Format(SR.Argument_CultureIetfNotSupported, name));
}
Expand Down
Loading