Author: atsushi
Date: 2005-07-08 09:28:21 -0400 (Fri, 08 Jul 2005)
New Revision: 47098
Modified:
trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog
trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
trunk/mcs/class/corlib/Mono.Globalization.Unicode/SortKey.cs
Log:
2005-07-08 Atsushi Enomoto <[EMAIL PROTECTED]>
* SortKey.cs : It borked when MONO_USE_MANAGED_COLLATION is not yes.
* SimpleCollator.cs : support for extender (U+309D etc.).
Modified: trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog 2005-07-08
13:22:05 UTC (rev 47097)
+++ trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog 2005-07-08
13:28:21 UTC (rev 47098)
@@ -1,5 +1,10 @@
2005-07-08 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * SortKey.cs : It borked when MONO_USE_MANAGED_COLLATION is not yes.
+ * SimpleCollator.cs : support for extender (U+309D etc.).
+
+2005-07-08 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* create-mscompat-collation-table.cs : some punct/symbols fix.
* managed-collation.patch : new (and temporary) file to support
managed collation in mscorlib.
Modified: trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
===================================================================
--- trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
2005-07-08 13:22:05 UTC (rev 47097)
+++ trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
2005-07-08 13:28:21 UTC (rev 47098)
@@ -485,45 +485,100 @@
buf.Initialize (options, s, frenchSort);
int end = start + length;
+ previousSortKey = null;
GetSortKey (s, start, end);
return buf.GetResultAndReset ();
}
+ int previousChar = -1;
+ byte [] previousSortKey = null;
+
+ enum ExtenderType {
+ None,
+ Simple,
+ Voiced,
+ Conditional
+ }
+
+ ExtenderType GetExtenderType (int i)
+ {
+ // LAMESPEC: Windows expects true for U+3005, but
+ // sometimes it does not represent to repeat just
+ // one character.
+ // Windows also expects true for U+3031 and U+3032,
+ // but they should *never* repeat one character.
+
+ if (i < 0x309D || i > 0xFF70)
+ return ExtenderType.None;
+ if (i == 0xFE7C || i == 0xFE7D || i == 0xFF70)
+ return ExtenderType.Simple;
+ if (i > 0x30FE)
+ return ExtenderType.None;
+ if (i == 0x309D || i == 0x30FD)
+ return ExtenderType.Simple;
+ if (i == 0x309E || i == 0x30FE)
+ return ExtenderType.Voiced;
+ if (i == 0x30FC)
+ return ExtenderType.Conditional;
+ return ExtenderType.None;
+ }
+
+ bool IsIgnorable (int i)
+ {
+ return Uni.IsIgnorable (i) ||
+ ignoreSymbols && Uni.IsIgnorableSymbol (i);
+ }
+
void GetSortKey (string s, int start, int end)
{
for (int n = start; n < end; n++) {
int i = s [n];
+
+ ExtenderType ext = GetExtenderType (i);
+ if (ext != ExtenderType.None) {
+ i = previousChar;
+ if (i < 0) {
+ byte [] b = previousSortKey;
+ buf.AppendNormal (
+ b [0],
+ b [1],
+ b [2] != 1 ? b [2] :
Level2 (i),
+ b [3] != 1 ? b [3] :
level3 [lv3Indexer.ToIndex (i)]);
+ } else
+ FillSortKeyRaw (i,
+ ext ==
ExtenderType.Conditional);
+ continue;
+ }
+
if (IsIgnorable (i))
continue;
i = FilterOptions (i);
Contraction ct = GetContraction (s, n, end);
if (ct != null) {
- if (ct.Replacement != null)
+ if (ct.Replacement != null) {
GetSortKey (ct.Replacement, 0,
ct.Replacement.Length);
- else {
+ } else {
byte [] b = ct.SortKey;
buf.AppendNormal (
b [0],
b [1],
b [2] != 1 ? b [2] :
Level2 (i),
b [3] != 1 ? b [3] :
level3 [lv3Indexer.ToIndex (i)]);
+ previousSortKey = b;
+ previousChar = -1;
}
n += ct.Source.Length - 1;
}
- else
- FillSortKeyRaw (i);
+ else {
+ previousChar = i;
+ FillSortKeyRaw (i, false);
+ }
}
}
- bool IsIgnorable (int i)
+ void FillSortKeyRaw (int i, bool kanaExtender)
{
- return Uni.IsIgnorable (i) ||
- ignoreSymbols && Uni.IsIgnorableSymbol (i);
- }
-
- void FillSortKeyRaw (int i)
- {
if (0x3400 <= i && i <= 0x4DB5) {
int diff = i - 0x3400;
buf.AppendCJKExtension (
@@ -547,10 +602,13 @@
return;
}
- if (Uni.HasSpecialWeight ((char) i))
+ if (Uni.HasSpecialWeight ((char) i)) {
+ byte level1 = Level1 (i);
+ if (kanaExtender)
+ level1 = (byte) ((level1 & 0xF) % 8);
buf.AppendKana (
Category (i),
- Level1 (i),
+ level1,
Level2 (i),
Uni.Level3 (i),
Uni.IsJapaneseSmallLetter ((char) i),
@@ -558,6 +616,7 @@
!Uni.IsHiragana ((char) i),
Uni.IsHalfWidthKana ((char) i)
);
+ }
else
buf.AppendNormal (
Category (i),
Modified: trunk/mcs/class/corlib/Mono.Globalization.Unicode/SortKey.cs
===================================================================
--- trunk/mcs/class/corlib/Mono.Globalization.Unicode/SortKey.cs
2005-07-08 13:22:05 UTC (rev 47097)
+++ trunk/mcs/class/corlib/Mono.Globalization.Unicode/SortKey.cs
2005-07-08 13:28:21 UTC (rev 47098)
@@ -26,7 +26,9 @@
#endregion
readonly string source;
+ readonly CompareOptions options;
readonly byte [] key;
+ readonly int lcid;
/*
readonly int lv1Length;
readonly int lv2Length;
@@ -37,8 +39,6 @@
readonly int kanaWidthLength;
readonly int identLength;
*/
- readonly CompareOptions options;
- readonly int lcid;
// for legacy unmanaged one
internal SortKey (int lcid, string source, CompareOptions opt)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches