*** empty log message ***
authorhanda <handa>
Mon, 5 Jan 2009 14:40:14 +0000 (14:40 +0000)
committerhanda <handa>
Mon, 5 Jan 2009 14:40:14 +0000 (14:40 +0000)
MText.cs
Makefile
temp.cs [new file with mode: 0644]

index 090d58b..477d7e6 100644 (file)
--- a/MText.cs
+++ b/MText.cs
@@ -1,8 +1,10 @@
 using System;
 using System;
+using System.Text;
 using M17N.Core;
 
 namespace M17N.Core
 {
 using M17N.Core;
 
 namespace M17N.Core
 {
+#if false
   public enum MTextFormat
   {
     MTEXT_FORMAT_US_ASCII,
   public enum MTextFormat
   {
     MTEXT_FORMAT_US_ASCII,
@@ -12,9 +14,14 @@ namespace M17N.Core
     MTEXT_FORMAT_UTF_32BE,
     MTEXT_FORMAT_UTF_32LE,
   }
     MTEXT_FORMAT_UTF_32BE,
     MTEXT_FORMAT_UTF_32LE,
   }
+#endif
 
   public class MText
   {
 
   public class MText
   {
+#if false
+    public enum MTextFormat format;
+#endif
+
     private class MTextPlist : MPlist
     {
       public class MInterval
     private class MTextPlist : MPlist
     {
       public class MInterval
@@ -31,20 +38,42 @@ namespace M17N.Core
       {
        head = tail = new MInterval ();
        head.start = 0;
       {
        head = tail = new MInterval ();
        head.start = 0;
-       head.end = mt.nchars;
+       head.end = mt.sb.Length;
       }
     }
 
       }
     }
 
-    private string str;
-    private int nchars;
-    private int nunits;
+    private StringBuilder sb;
     private int cache_pos;
     private int cache_idx;
     private MTextPlist plist;
 
     private int cache_pos;
     private int cache_idx;
     private MTextPlist plist;
 
-    public MText (byte str, MTextFormat format)
+    private static UTF8Encoding utf8 = new UTF8Encoding ();
+
+    public MText ()
+    {
+      cache_pos = cache_idx = 0;
+      plist = null;
+      sb = new StringBuilder ();
+    }
+
+    public MText (byte[] str)
+    {
+      cache_pos = cache_idx = 0;
+      plist = null;          
+      sb = new StringBuilder (utf8.GetString (str));
+    }
+
+    public MText (String str)
+    {
+      cache_pos = cache_idx = 0;
+      plist = null;          
+      sb = new StringBuilder (str);
+    }
+
+    public int this[int i]
     {
     {
-      
+      set { this.sb[i] = (char) value; }
+      get { return this.sb[i]; }
     }
   }
 
     }
   }
 
index 959f128..5a66d8a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,16 @@
-CORE_SRC = MSymbol.cs MPlist.cs MText.cs temp.cs
+CORE_SRC = MSymbol.cs MPlist.cs MText.cs
+CS=gmcs
 
 all: M17N.exe temp.exe
 
 
 all: M17N.exe temp.exe
 
-M17N.exe: M17N.cs M17NCore.dll
-       mcs /r:M17NCore M17N.cs
-
 M17NCore.dll: ${CORE_SRC}
 M17NCore.dll: ${CORE_SRC}
-       mcs /out:$@ /t:library ${CORE_SRC}
+       $(CS) /out:$@ /t:library ${CORE_SRC}
+
+M17N.exe: M17N.cs M17NCore.dll
+       $(CS) /r:M17NCore M17N.cs
 
 temp.exe: temp.cs M17NCore.dll
 
 temp.exe: temp.cs M17NCore.dll
-       mcs /r:M17NCore temp.cs
+       $(CS) /r:M17NCore temp.cs
 
 clean:
        rm -f *.dll *.exe
 
 clean:
        rm -f *.dll *.exe
diff --git a/temp.cs b/temp.cs
new file mode 100644 (file)
index 0000000..c110b7e
--- /dev/null
+++ b/temp.cs
@@ -0,0 +1,15 @@
+using System;
+using M17N.Core;
+
+public class Test
+{
+  public static void Main()
+  {
+    MText mt = new MText ("a𝄀あc");
+
+    Console.WriteLine (mt[0]);
+    Console.WriteLine (mt[1]);
+    Console.WriteLine (mt[2]);
+    Console.WriteLine (mt[3]);
+  }
+}