Skip to content

Commit eca9496

Browse files
committed
Added CurrentCulture.InvariantCulture for ToUpper on Autokey encoder
1 parent 3cd6860 commit eca9496

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Algorithms.Tests/Encoders/AutokeyEncoderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Algorithms.Tests.Encoders
77
{
8-
public class AutokeyEncoderTests
8+
public static class AutokeyEncoderTests
99
{
1010
[Test]
1111
public static void DecodedStringIsTheSame()

Algorithms/Encoders/AutokeyEncorder.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Globalization;
23
using System.Text;
34
using System.Text.RegularExpressions;
45

@@ -19,8 +20,8 @@ public class AutokeyEncorder
1920
/// <returns>The Autokey encoded string (All Uppercase).</returns>
2021
public string Encode(string plainText, string keyword)
2122
{
22-
plainText = Regex.Replace(plainText.ToUpper(), "[^A-Z]", string.Empty);
23-
keyword = keyword.ToUpper();
23+
plainText = Regex.Replace(plainText.ToUpper(CultureInfo.InvariantCulture), "[^A-Z]", string.Empty);
24+
keyword = keyword.ToUpper(CultureInfo.InvariantCulture);
2425

2526
keyword += plainText;
2627

@@ -46,8 +47,8 @@ public string Encode(string plainText, string keyword)
4647
/// <returns>The plaintext (All Uppercase).</returns>
4748
public string Decode(string cipherText, string keyword)
4849
{
49-
cipherText = Regex.Replace(cipherText.ToUpper(), "[^A-Z]", string.Empty);
50-
keyword = keyword.ToUpper();
50+
cipherText = Regex.Replace(cipherText.ToUpper(CultureInfo.InvariantCulture), "[^A-Z]", string.Empty);
51+
keyword = keyword.ToUpper(CultureInfo.InvariantCulture);
5152

5253
StringBuilder plainText = new StringBuilder();
5354
StringBuilder extendedKeyword = new StringBuilder(keyword);

0 commit comments

Comments
 (0)