From: Gustavo Martin Date: Mon, 16 Jun 2014 07:29:38 +0000 (+0200) Subject: Collation project for Windows8 and Mono X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=7c68da3638c828240f73bf4c0965ee019c775e1a;p=CSharpForFun%2F.git Collation project for Windows8 and Mono --- diff --git a/Allgemeines/Collation/Collation.Monodevelop.sln b/Allgemeines/Collation/Collation.Monodevelop.sln new file mode 100644 index 0000000..460821e --- /dev/null +++ b/Allgemeines/Collation/Collation.Monodevelop.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Collation", "Collation\Collation.Monodevelop.csproj", "{85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0}.Debug|x86.ActiveCfg = Debug|x86 + {85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0}.Debug|x86.Build.0 = Debug|x86 + {85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0}.Release|x86.ActiveCfg = Release|x86 + {85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = Collation.csproj + EndGlobalSection +EndGlobal diff --git a/Allgemeines/Collation/Collation.Windows8.sln b/Allgemeines/Collation/Collation.Windows8.sln new file mode 100644 index 0000000..7281a46 --- /dev/null +++ b/Allgemeines/Collation/Collation.Windows8.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30110.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Collation", "Collation\Collation.Windows8.csproj", "{19C2AA8B-1FE5-49B8-A12D-0CFBC478EEC9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {19C2AA8B-1FE5-49B8-A12D-0CFBC478EEC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19C2AA8B-1FE5-49B8-A12D-0CFBC478EEC9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19C2AA8B-1FE5-49B8-A12D-0CFBC478EEC9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19C2AA8B-1FE5-49B8-A12D-0CFBC478EEC9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Allgemeines/Collation/Collation.csproj b/Allgemeines/Collation/Collation.csproj deleted file mode 100644 index 077445a..0000000 --- a/Allgemeines/Collation/Collation.csproj +++ /dev/null @@ -1,43 +0,0 @@ - - - - Debug - x86 - 10.0.0 - 2.0 - {85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0} - Exe - Collation - Collation - Collation with Mono and C# - v4.5 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - true - x86 - - - full - true - bin\Release - prompt - 4 - true - x86 - - - - - - - - - - \ No newline at end of file diff --git a/Allgemeines/Collation/Collation.sln b/Allgemeines/Collation/Collation.sln deleted file mode 100644 index d2fc79d..0000000 --- a/Allgemeines/Collation/Collation.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Collation", "Collation.csproj", "{85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0}.Debug|x86.ActiveCfg = Debug|x86 - {85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0}.Debug|x86.Build.0 = Debug|x86 - {85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0}.Release|x86.ActiveCfg = Release|x86 - {85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = Collation.csproj - EndGlobalSection -EndGlobal diff --git a/Allgemeines/Collation/Collation/App.config b/Allgemeines/Collation/Collation/App.config new file mode 100644 index 0000000..9c05822 --- /dev/null +++ b/Allgemeines/Collation/Collation/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Allgemeines/Collation/Collation/Collation.Monodevelop.csproj b/Allgemeines/Collation/Collation/Collation.Monodevelop.csproj new file mode 100644 index 0000000..077445a --- /dev/null +++ b/Allgemeines/Collation/Collation/Collation.Monodevelop.csproj @@ -0,0 +1,43 @@ + + + + Debug + x86 + 10.0.0 + 2.0 + {85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0} + Exe + Collation + Collation + Collation with Mono and C# + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + x86 + + + full + true + bin\Release + prompt + 4 + true + x86 + + + + + + + + + + \ No newline at end of file diff --git a/Allgemeines/Collation/Collation/Collation.Windows8.csproj b/Allgemeines/Collation/Collation/Collation.Windows8.csproj new file mode 100644 index 0000000..29118fc --- /dev/null +++ b/Allgemeines/Collation/Collation/Collation.Windows8.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {19C2AA8B-1FE5-49B8-A12D-0CFBC478EEC9} + Exe + Properties + Collation.Windows8 + Collation.Windows8 + v4.5.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Allgemeines/Collation/Collation/Program.cs b/Allgemeines/Collation/Collation/Program.cs new file mode 100644 index 0000000..4cbd4e4 --- /dev/null +++ b/Allgemeines/Collation/Collation/Program.cs @@ -0,0 +1,97 @@ +using System; +using System.Globalization; +using System.Collections; + +namespace Collation +{ + class MainClass + { + public static void Main (string[] args) + { + string string1 = "hello gus"; + string string2 = "HELLO GUS"; + int compareResult = 0; + + // Like Java String.compareTo (without culture, + // using unicode values directly) + compareResult = String.Compare(string1, string2, + StringComparison.Ordinal); + Console.WriteLine("{0} comparison of '{1}' and '{2}': {3}", + StringComparison.Ordinal, string1, string2, + compareResult); + + // Like Java String.compareToIgnoreCase (without culture, + // using unicode values directly) + compareResult = String.Compare(string1, string2, + StringComparison.OrdinalIgnoreCase); + Console.WriteLine("{0} comparison of '{1}' and '{2}': {3}", + StringComparison.OrdinalIgnoreCase, string1, string2, + compareResult); + + // Like Java String.toLowerCase(Locale.ENGLISH) + string key = "HELLO GUS"; + string lowerKey = key.ToLower (CultureInfo.InvariantCulture); + Console.WriteLine ("Key: {0}", lowerKey); + + string[] words = {"cote", "coté", "côte", "côté"}; + + // C# unlike Java does not implement Levels/Strengths collation configurations. + // It always uses the five levels, see: Mono.Globalization.Unicode/SimpleCollator.cs + + // InvariantCulture: English like Java: Locale.ENGLISH + Array.Sort (words, StringComparer.InvariantCulture); + Console.WriteLine("Words list Invariant: "); + printValues (words); + + // without culture, using unicode values directly + Array.Sort (words, StringComparer.Ordinal); + Console.WriteLine("Words list Ordinal: "); + printValues (words); + + // like Java new Locale("es","ES") + CultureInfo cultureES = CultureInfo.CreateSpecificCulture ("es-ES"); + IComparer cultureComparerES =new CaseInsensitiveComparer (cultureES); + Array.Sort (words, cultureComparerES); + Console.WriteLine("Words list ES: "); + printValues (words); + + CultureInfo cultureFR = CultureInfo.CreateSpecificCulture ("fr-FR"); + IComparer cultureComparerFR =new CaseInsensitiveComparer (cultureFR); + Array.Sort (words, cultureComparerFR); + Console.WriteLine("Words list FR: "); + printValues (words); + + // It is the same word in German, as expected. + // I DO NOT GET THE SAME RESULTS FOR THIS COMPARISON USING JAVA!!!! O.o WTF!!! :( + 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? + // IN THIS CASE I GET THE SAME RESULTS USING JAVA :) + 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); + + Console.ReadLine(); + } + + private static void printValues(string[] words) + { + foreach (var word in words) + { + Console.Write ("{0} ", word); + } + + Console.WriteLine (); + } + } +} diff --git a/Allgemeines/Collation/Collation/Properties/AssemblyInfo.cs b/Allgemeines/Collation/Collation/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f3925b8 --- /dev/null +++ b/Allgemeines/Collation/Collation/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// La información general sobre un ensamblado se controla mediante el siguiente +// conjunto de atributos. Cambie estos atributos para modificar la información +// asociada con un ensamblado. +[assembly: AssemblyTitle("Collation.Windows8")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Collation.Windows8")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Si establece ComVisible como false, los tipos de este ensamblado no estarán visibles +// para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde +// COM, establezca el atributo ComVisible como true en este tipo. +[assembly: ComVisible(false)] + +// El siguiente GUID sirve como identificador de typelib si este proyecto se expone a COM +[assembly: Guid("b7e2adaa-1fed-4ede-953b-7e48d1da2261")] + +// La información de versión de un ensamblado consta de los cuatro valores siguientes: +// +// Versión principal +// Versión secundaria +// Número de compilación +// Revisión +// +// Puede especificar todos los valores o establecer como predeterminados los números de compilación y de revisión +// mediante el carácter '*', como se muestra a continuación: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Allgemeines/Collation/Program.cs b/Allgemeines/Collation/Program.cs deleted file mode 100644 index 0a1c720..0000000 --- a/Allgemeines/Collation/Program.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Globalization; -using System.Collections; - -namespace Collation -{ - class MainClass - { - public static void Main (string[] args) - { - string string1 = "hello gus"; - string string2 = "HELLO GUS"; - int compareResult = 0; - - // Like Java String.compareTo (without culture, - // using unicode values directly) - compareResult = String.Compare(string1, string2, - StringComparison.Ordinal); - Console.WriteLine("{0} comparison of '{1}' and '{2}': {3}", - StringComparison.Ordinal, string1, string2, - compareResult); - - // Like Java String.compareToIgnoreCase (without culture, - // using unicode values directly) - compareResult = String.Compare(string1, string2, - StringComparison.OrdinalIgnoreCase); - Console.WriteLine("{0} comparison of '{1}' and '{2}': {3}", - StringComparison.OrdinalIgnoreCase, string1, string2, - compareResult); - - // Like Java String.toLowerCase(Locale.ENGLISH) - string key = "HELLO GUS"; - string lowerKey = key.ToLower (CultureInfo.InvariantCulture); - Console.WriteLine ("Key: {0}", lowerKey); - - string[] words = {"cote", "coté", "côte", "côté"}; - - // C# unlike Java does not implement Levels/Strengths collation configurations. - // It always uses the five levels, see: Mono.Globalization.Unicode/SimpleCollator.cs - - // InvariantCulture: English like Java: Locale.ENGLISH - Array.Sort (words, StringComparer.InvariantCulture); - Console.WriteLine("Words list Invariant: "); - printValues (words); - - // without culture, using unicode values directly - Array.Sort (words, StringComparer.Ordinal); - Console.WriteLine("Words list Ordinal: "); - printValues (words); - - // like Java new Locale("es","ES") - CultureInfo cultureES = CultureInfo.CreateSpecificCulture ("es-ES"); - IComparer cultureComparerES =new CaseInsensitiveComparer (cultureES); - Array.Sort (words, cultureComparerES); - Console.WriteLine("Words list ES: "); - printValues (words); - - CultureInfo cultureFR = CultureInfo.CreateSpecificCulture ("fr-FR"); - IComparer cultureComparerFR =new CaseInsensitiveComparer (cultureFR); - Array.Sort (words, cultureComparerFR); - Console.WriteLine("Words list FR: "); - printValues (words); - - // It is the same word in German, as expected. - // I DO NOT GET THE SAME RESULTS FOR THIS COMPARISON USING JAVA!!!! O.o WTF!!! :( - 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? - // IN THIS CASE I GET THE SAME RESULTS USING JAVA :) - 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) - { - foreach (var word in words) - { - Console.Write ("{0} ", word); - } - - Console.WriteLine (); - } - } -}