From: handa Date: Wed, 7 Jan 2009 00:07:57 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=1371fb1b682f588d096e0e9a6959805f18f2b1f7;p=m17n%2Fm17n-lib-cs.git *** empty log message *** --- diff --git a/MText.cs b/MText.cs index 5d9fbf8..7a496a5 100644 --- a/MText.cs +++ b/MText.cs @@ -101,6 +101,11 @@ namespace M17N.Core return mt; } + public override string ToString () + { + return sb.ToString (); + } + private static bool surrogate_high_p (char c) { return (c >= 0xD800 && c < 0xDC00); @@ -183,7 +188,11 @@ namespace M17N.Core set { i = pos_to_idx (this, i); if (value < 0x10000) - sb[i] = (char) value; + { + if (surrogate_high_p (sb[i])) + sb.Remove (i, 1); + sb[i] = (char) value; + } else { char high = (char) (0xD800 + ((i - 0x10000) >> 10)); diff --git a/temp.cs b/temp.cs index c110b7e..ae5d9e2 100644 --- a/temp.cs +++ b/temp.cs @@ -11,5 +11,10 @@ public class Test Console.WriteLine (mt[1]); Console.WriteLine (mt[2]); Console.WriteLine (mt[3]); + Console.WriteLine (mt + new MText ("漢字")); + mt[1] = 'b'; + Console.WriteLine (mt); + mt[1] = 0x1d100; + Console.WriteLine (mt); } }