From 1371fb1b682f588d096e0e9a6959805f18f2b1f7 Mon Sep 17 00:00:00 2001 From: handa Date: Wed, 7 Jan 2009 00:07:57 +0000 Subject: [PATCH] *** empty log message *** --- MText.cs | 11 ++++++++++- temp.cs | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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); } } -- 1.7.10.4