summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRion Williams <rionmonster@gmail.com>2017-03-15 19:38:04 -0500
committerTarek Mahmoud Sayed <tarekms@microsoft.com>2017-03-15 17:38:04 -0700
commit50232d6448e63ccd04fa9e92199292621b049d5c (patch)
treea3e847df723031143d5f435e6c2b6964d5833364 /src
parent1af419659034d9297b95240e889e4571ccefa710 (diff)
downloadcoreclr-50232d6448e63ccd04fa9e92199292621b049d5c.tar.gz
coreclr-50232d6448e63ccd04fa9e92199292621b049d5c.tar.bz2
coreclr-50232d6448e63ccd04fa9e92199292621b049d5c.zip
Fix ToTitleCase Functionality for Dutch Cultures (#10195)
* Add Methods to Handle Dutch Titlecasing Added the `IsDutchCulture` and `IsIjAtCurrentPosition` methods to handle resolving a special-case for Dutch titlecasing, which should properly capitalize any instances of "IJ" at the beginning of a titlecased word. * Moved `IsDutchCase()` Call Into Local Variable Moved the check for Dutch culture outside of the title-loop to avoid unnecessary evaluations. * Performance Changes and Improvements to Dutch Titlecasing Removed `IsDutchCulture()` method in favor of an inline approach relying on the `StartsWith()` method; Remove the `IsIjAtCurrentPosition()` method in favor of another inline approach to improve performance. * Minor Formatting Change Added space for `isDutchCulture` line, as it managed to disappear somewhere along the way.
Diffstat (limited to 'src')
-rw-r--r--src/mscorlib/src/System/Globalization/TextInfo.cs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/mscorlib/src/System/Globalization/TextInfo.cs b/src/mscorlib/src/System/Globalization/TextInfo.cs
index 00a416ef09..b5e4e3d9c2 100644
--- a/src/mscorlib/src/System/Globalization/TextInfo.cs
+++ b/src/mscorlib/src/System/Globalization/TextInfo.cs
@@ -473,6 +473,8 @@ namespace System.Globalization
StringBuilder result = new StringBuilder();
string lowercaseData = null;
+ // Store if the current culture is Dutch (special case)
+ bool isDutchCulture = CultureName.StartsWith("nl-", StringComparison.OrdinalIgnoreCase);
for (int i = 0; i < str.Length; i++)
{
@@ -482,8 +484,18 @@ namespace System.Globalization
charType = CharUnicodeInfo.InternalGetUnicodeCategory(str, i, out charLen);
if (Char.CheckLetter(charType))
{
- // Do the titlecasing for the first character of the word.
- i = AddTitlecaseLetter(ref result, ref str, i, charLen) + 1;
+ // Special case to check for Dutch specific titlecasing with "IJ" characters
+ // at the beginning of a word
+ if (isDutchCulture && i < str.Length - 1 && (str[i] == 'i' || str[i] == 'I') && (str[i+1] == 'j' || str[i+1] == 'J'))
+ {
+ result.Append("IJ");
+ i += 2;
+ }
+ else
+ {
+ // Do the titlecasing for the first character of the word.
+ i = AddTitlecaseLetter(ref result, ref str, i, charLen) + 1;
+ }
//
// Convert the characters until the end of the this word