Example #1
0
        public string ReadAnsiString()
        {
            const int SZ_BUFF = 0x100;
            byte *    prem    = _base;
            byte *    pbuff   = stackalloc byte[SZ_BUFF + 1];
            char *    pchar   = stackalloc char[SZ_BUFF];

            System.Text.StringBuilder build = new System.Text.StringBuilder();

            pbuff[SZ_BUFF] = 0;           // sentinel
            lock (dec){
                dec.Reset();
                int cByts, cChrs;
                do
                {
                    // prem → pbuff
                    mem.ReadMemory(prem, pbuff, SZ_BUFF); prem += SZ_BUFF;
                    byte *scn = pbuff; while (*scn != 0)
                    {
                        scn++;                                               // null 文字の位置迄
                    }
                    cByts = (int)(scn - pbuff);

                    // pbuff → pchar
                    cChrs = dec.GetChars(pbuff, cByts, pchar, SZ_BUFF, false);

                    // pchar → build
                    build.Append(new string(pchar, 0, cChrs));
                }while(cByts == SZ_BUFF);
            }
            return(build.ToString());
        }
Example #2
0
 /// <summary>Sets the decoder back to its initial state</summary>
 public override void Reset()
 {
     mDec.Reset();
 }