C# trying out Collation
authorgu.martinm@gmail.com <gu.martinm@gmail.com>
Wed, 26 Mar 2014 19:09:01 +0000 (20:09 +0100)
committergu.martinm@gmail.com <gu.martinm@gmail.com>
Wed, 26 Mar 2014 19:09:01 +0000 (20:09 +0100)
Allgemeines/Collation/Collation.csproj [new file with mode: 0644]
Allgemeines/Collation/Collation.sln [new file with mode: 0644]
Allgemeines/Collation/Program.cs [new file with mode: 0644]
Allgemeines/Collation/Properties/AssemblyInfo.cs [new file with mode: 0644]

diff --git a/Allgemeines/Collation/Collation.csproj b/Allgemeines/Collation/Collation.csproj
new file mode 100644 (file)
index 0000000..077445a
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>10.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{85DE1B80-0DFF-4B75-A84C-91BF5E5DAAF0}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>Collation</RootNamespace>
+    <AssemblyName>Collation</AssemblyName>
+    <Description>Collation with Mono and C#</Description>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Externalconsole>true</Externalconsole>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <DebugType>full</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Externalconsole>true</Externalconsole>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>
\ No newline at end of file
diff --git a/Allgemeines/Collation/Collation.sln b/Allgemeines/Collation/Collation.sln
new file mode 100644 (file)
index 0000000..d2fc79d
--- /dev/null
@@ -0,0 +1,20 @@
+
+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/Program.cs b/Allgemeines/Collation/Program.cs
new file mode 100644 (file)
index 0000000..ee6eeb3
--- /dev/null
@@ -0,0 +1,76 @@
+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);
+
+        }
+
+        private static void printValues(string[] words)
+        {
+            foreach (var word in words)
+            {
+                Console.Write ("{0} ", word);
+            }
+
+            Console.WriteLine ();
+        }
+    }
+}
diff --git a/Allgemeines/Collation/Properties/AssemblyInfo.cs b/Allgemeines/Collation/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..e638937
--- /dev/null
@@ -0,0 +1,22 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+[assembly: AssemblyTitle ("Collation")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("")]
+[assembly: AssemblyCopyright ("gmm003es")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+[assembly: AssemblyVersion ("1.0.*")]
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+