using System;
+using System.Text;
using M17N.Core;
namespace M17N.Core
{
+#if false
public enum MTextFormat
{
MTEXT_FORMAT_US_ASCII,
MTEXT_FORMAT_UTF_32BE,
MTEXT_FORMAT_UTF_32LE,
}
+#endif
public class MText
{
+#if false
+ public enum MTextFormat format;
+#endif
+
private class MTextPlist : MPlist
{
public class MInterval
{
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;
- 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]; }
}
}
-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
-M17N.exe: M17N.cs M17NCore.dll
- mcs /r:M17NCore M17N.cs
-
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
- mcs /r:M17NCore temp.cs
+ $(CS) /r:M17NCore temp.cs
clean:
rm -f *.dll *.exe
--- /dev/null
+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]);
+ }
+}