From cb5fe000c757b1c059f90c3b69a38d3cdb338d29 Mon Sep 17 00:00:00 2001 From: handa Date: Mon, 5 Jan 2009 14:40:14 +0000 Subject: [PATCH] *** empty log message *** --- MText.cs | 41 +++++++++++++++++++++++++++++++++++------ Makefile | 13 +++++++------ temp.cs | 15 +++++++++++++++ 3 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 temp.cs diff --git a/MText.cs b/MText.cs index 090d58b..477d7e6 100644 --- a/MText.cs +++ b/MText.cs @@ -1,8 +1,10 @@ using System; +using System.Text; using M17N.Core; namespace M17N.Core { +#if false public enum MTextFormat { MTEXT_FORMAT_US_ASCII, @@ -12,9 +14,14 @@ namespace M17N.Core 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 @@ -31,20 +38,42 @@ namespace M17N.Core { 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]; } } } diff --git a/Makefile b/Makefile index 959f128..5a66d8a 100644 --- 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 -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 diff --git a/temp.cs b/temp.cs new file mode 100644 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]); + } +} -- 1.7.10.4