From a8add00670f5431132bdee8a8d9c8d7308e9157c Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Mon, 16 Jun 2014 02:23:08 +0200 Subject: [PATCH] Trying to understand collations in C#. So far, doing bad :/ --- Allgemeines/Collation/Program.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Allgemeines/Collation/Program.cs b/Allgemeines/Collation/Program.cs index ee6eeb3..f96f2e9 100644 --- a/Allgemeines/Collation/Program.cs +++ b/Allgemeines/Collation/Program.cs @@ -61,6 +61,23 @@ namespace Collation Console.WriteLine("Words list FR: "); printValues (words); + // It is the same word in German, as expected. + string[] strasse = {"strasse", "straße" }; + Console.WriteLine("strasse "); + int result = String.Compare(strasse[0], strasse[1], CultureInfo.CreateSpecificCulture("de-DE"), CompareOptions.IgnoreCase); + Console.WriteLine("German result: {0}", result); + // And also in Spanish... why in Spanish is the same word? O.o + result = String.Compare(strasse[0], strasse[1], CultureInfo.GetCultureInfo("es-ES"), CompareOptions.IgnoreCase); + Console.WriteLine("Spanish result: {0}", result); + + // Shouldn't it be the same word in German? + string[] koennen = {"können", "koennen" }; + Console.WriteLine("koennen "); + result = String.Compare(koennen[0], koennen[1], CultureInfo.CreateSpecificCulture("de-DE"), CompareOptions.IgnoreCase); + Console.WriteLine("German result: {0}", result); + // Neither in German nor in Spanish they are the same word. I do not understand collations :( + result = String.Compare(koennen[0], koennen[1], CultureInfo.GetCultureInfo("es-ES"), CompareOptions.IgnoreCase); + Console.WriteLine("Spanish result: {0}", result); } private static void printValues(string[] words) -- 2.1.4