Author: atsushi
Date: 2005-06-29 06:29:56 -0400 (Wed, 29 Jun 2005)
New Revision: 46711
Modified:
trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.template
trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
Log:
2005-06-29 Atsushi Enomoto <[EMAIL PROTECTED]>
* SimpleCollator.cs : build culture specific tailoring table from
TailoringInfo and unified data array.
* create-mscompat-collation-table.cs : Added null termination to
sortkey map tailorings (mostly to save my eyes).
* MSCompatUnicodeTable.template : added public TailoringValues.
Modified: trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog 2005-06-29
09:50:30 UTC (rev 46710)
+++ trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog 2005-06-29
10:29:56 UTC (rev 46711)
@@ -1,5 +1,13 @@
2005-06-29 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * SimpleCollator.cs : build culture specific tailoring table from
+ TailoringInfo and unified data array.
+ * create-mscompat-collation-table.cs : Added null termination to
+ sortkey map tailorings (mostly to save my eyes).
+ * MSCompatUnicodeTable.template : added public TailoringValues.
+
+2005-06-29 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* SortKeyBuffer.cs : handle special weight (category 06) characters.
* Collation-notes.txt : Updated description on special weight (it was
incorrect).
Modified:
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.template
===================================================================
---
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.template
2005-06-29 09:50:30 UTC (rev 46710)
+++
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.template
2005-06-29 10:29:56 UTC (rev 46711)
@@ -23,6 +23,10 @@
internal class MSCompatUnicodeTable
{
+ public static char [] TailoringValues {
+ get { return tailorings; }
+ }
+
public static ushort [] CjkCHS {
get { return cjkCHS; }
}
Modified: trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
===================================================================
--- trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
2005-06-29 09:50:30 UTC (rev 46710)
+++ trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
2005-06-29 10:29:56 UTC (rev 46711)
@@ -5,6 +5,7 @@
//
using System;
+using System.Collections;
using System.Globalization;
using Uni = Mono.Globalization.Unicode.MSCompatUnicodeTable;
@@ -28,6 +29,46 @@
readonly byte [] cjkLv2Table;
readonly CodePointIndexer cjkLv2Indexer;
+ // Possible mapping types are:
+ //
+ // - string to string (ReplacementMap)
+ // - string to SortKey (SortKeyMap)
+ // - diacritical byte to byte (DiacriticalMap)
+ //
+ // There could be mapping from string to sortkeys, but
+ // for now there is none as such.
+ //
+ internal class Contraction
+ {
+ public readonly char [] Source;
+ // only either of them is used.
+ public readonly string Replacement;
+ public readonly byte [] SortKey;
+
+ public Contraction (char [] source,
+ string replacement, byte [] sortkey)
+ {
+ Source = source;
+ Replacement = replacement;
+ SortKey = sortkey;
+ }
+ }
+
+ internal struct Level2Map
+ {
+ public byte Source;
+ public byte Replace;
+
+ public Level2Map (byte source, byte replace)
+ {
+ Source = source;
+ Replace = replace;
+ }
+ }
+
+ readonly Contraction [] contractions;
+ readonly Level2Map [] level2Maps;
+
public SimpleCollator (CultureInfo culture)
{
textInfo = culture.TextInfo;
@@ -47,9 +88,79 @@
t = Uni.GetTailoringInfo (127);
frenchSort = t.FrenchSort;
- // FIXME: collect tailoring entries.
+ BuildTailoringTables (culture, t, ref contractions,
+ ref level2Maps);
+/*
+Console.WriteLine ("******** building table for {0} : c - {1} d - {2}",
+culture.LCID, contractions.Length, level2Maps.Length);
+foreach (Contraction c in contractions) {
+foreach (char cc in c.Source)
+Console.Write ("{0:X4} ", (int) cc);
+Console.WriteLine (" -> {0}", c.Replacement);
+}
+*/
}
+ private void BuildTailoringTables (CultureInfo culture,
+ TailoringInfo t,
+ ref Contraction [] contractions,
+ ref Level2Map [] diacriticals)
+ {
+ // collect tailoring entries.
+ ArrayList cmaps = new ArrayList ();
+ ArrayList dmaps = new ArrayList ();
+ char [] tarr = Uni.TailoringValues;
+ int idx = t.TailoringIndex;
+ int end = idx + t.TailoringCount;
+ while (idx < end) {
+ int ss = idx + 1;
+ char [] src = null;
+ switch (tarr [idx]) {
+ case '\x1': // SortKeyMap
+ idx++;
+ while (tarr [ss] != 0)
+ ss++;
+ src = new char [ss - idx];
+ Array.Copy (tarr, idx, src, 0, ss -
idx);
+ byte [] sortkey = new byte [5];
+ for (int i = 0; i < 5; i++)
+ sortkey [i] = (byte) tarr [ss +
1 + i];
+ cmaps.Add (new Contraction (
+ src, null, sortkey));
+ // it ends with 0
+ idx = ss + 6;
+ break;
+ case '\x2': // DiacriticalMap
+ dmaps.Add (new Level2Map (
+ (byte) tarr [idx + 1],
+ (byte) tarr [idx + 2]));
+ idx += 3;
+ break;
+ case '\x3': // ReplacementMap
+ idx++;
+ while (tarr [ss] != 0)
+ ss++;
+ src = new char [ss - idx];
+ Array.Copy (tarr, idx, src, 0, ss -
idx);
+ int l = ss + 1;
+ while (tarr [l] != 0)
+ l++;
+ string r = new string (tarr, ss, l -
ss);
+ cmaps.Add (new Contraction (
+ src, r, null));
+ idx = l + 1;
+ break;
+ default:
+ throw new NotImplementedException
(String.Format ("Mono INTERNAL ERROR (Should not happen): Collation tailoring
table is broken for culture {0} ({1}) at 0x{2:X}", culture.LCID, culture.Name,
idx));
+ }
+ }
+ // FIXME: sort contractions and lv2maps
+ contractions = cmaps.ToArray (typeof (Contraction))
+ as Contraction [];
+ diacriticals = dmaps.ToArray (typeof (Level2Map))
+ as Level2Map [];
+ }
+
private void SetCJKTable (CultureInfo culture,
ref ushort [] cjkTable, ref CodePointIndexer cjkIndexer,
ref byte [] cjkLv2Table, ref CodePointIndexer
cjkLv2Indexer)
@@ -119,9 +230,10 @@
this.ignoreKanaType = (options &
CompareOptions.IgnoreKanaType) != 0;
}
+ // FIXME: It should not be used, since it disregards both
+ // sortkey maps and replacement map from two or more chars.
string GetExpansion (int i)
{
- // FIXME: handle tailorings
return Uni.GetExpansion ((char) i);
}
Modified:
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
===================================================================
---
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
2005-06-29 09:50:30 UTC (rev 46710)
+++
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
2005-06-29 10:29:56 UTC (rev 46711)
@@ -3549,7 +3549,7 @@
public char [] ToCharArray ()
{
- char [] ret = new char [Source.Length + 7];
+ char [] ret = new char [Source.Length + 8];
ret [0] = (char) 01; // kind:SortKeyMap
for (int i = 0; i < Source.Length; i++)
ret [i + 1] = Source [i];
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches