diff --git a/src/CodingAlphabet.cs b/src/CodingAlphabet.cs index 37f0e91..f51c77e 100644 --- a/src/CodingAlphabet.cs +++ b/src/CodingAlphabet.cs @@ -54,7 +54,7 @@ public CodingAlphabet(int length, string alphabet, bool caseInsensitive = false) char c = alphabet[i]; if (caseInsensitive && char.IsLetter(c)) { - char c2 = char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c); + char c2 = char.IsUpper(c) ? char.ToLowerInvariant(c) : char.ToUpperInvariant(c); if (alphabet.Contains(c2)) { throw new ArgumentException($"Case-sensitivity can't be selected with an alphabet that contains both cases of the same letter", nameof(caseInsensitive)); diff --git a/test/CodingAlphabetTest.cs b/test/CodingAlphabetTest.cs index bed7b19..ec9c361 100644 --- a/test/CodingAlphabetTest.cs +++ b/test/CodingAlphabetTest.cs @@ -26,6 +26,10 @@ class DummyAlphabet(string alphabet) : CodingAlphabet(10, alphabet, caseInsensit { } + class DummyAutoAlphabet(string alphabet, bool caseInsensitive) : CodingAlphabet(alphabet.Length, alphabet, caseInsensitive) + { + } + [Test] public void Ctor_WithBothCasesOfLettersAndCaseInsensitive_ShouldThrow() { @@ -43,4 +47,18 @@ public void Ctor_ProperArguments_ShouldNotThrow() { Assert.DoesNotThrow(() => new DummyAlphabet("01234567ab")); } + + [Test] + [SetCulture("tr-TR")] + public void Ctor_ShouldNotThrow_On_Turkish_Locale_With_Lowercase_I() + { + Assert.DoesNotThrow(() => new DummyAutoAlphabet("i", true)); + } + + [Test] + [SetCulture("tr-TR")] + public void Ctor_ShouldNotThrow_On_Turkish_Locale_With_Uppercase_I() + { + Assert.DoesNotThrow(() => new DummyAutoAlphabet("I", true)); + } }