public static ByteCollection operator +(ByteCollection bc1, ByteCollection bc2)
        {
            ByteCollection bc = new ByteCollection(bc1.Count + bc2.Count);

            bc.Add(bc1);
            bc.Add(bc2);
            return(bc);
        }
        public static ByteCollection operator +(ByteCollection bc1, string bc2String)
        {
            ByteCollection bc2 = StringToByteCollection(bc2String);
            ByteCollection bc  = new ByteCollection(bc1.Count + bc2.Count);

            bc.Add(bc1);
            bc.Add(bc2);
            return(bc);
        }
Example #3
0
        public byte[] CPConvert(byte[] msg, int cpFrom, int cpTo)
        {
            //			if (cpFrom != 0 || (cpFrom = this.DetectCodePage(text)) != 0)
            //			{
            Encoding  enc    = Encoding.UTF8;
            ArrayList fromAL = GetHrBytes(cpFrom);
            ArrayList toAL   = GetHrBytes(cpTo);

            ByteCollection ret = new ByteCollection(msg.Length);
            int            i   = 0;

            while (i < msg.Length)
            {
                if (msg[i] == 0x1b)
                {
                    ret.Add(msg[i]);
                    i++;
                }
                else
                {
                    bool fnd = false;
                    int  j;
                    for (j = 0; j < fromAL.Count; j++)
                    {
                        byte[] ba = (byte[])fromAL[j];
                        if (ArrayCompare(msg, i, ba) == 0)
                        {
                            i  += ba.Length;
                            fnd = true;
                            break;
                        }
                    }
                    if (fnd)
                    {
                        foreach (byte b in (byte[])toAL[j])
                        {
                            ret.Add(b);
                        }
                        continue;
                    }
                }
                ret.Add(msg[i++]);
            }
            return(ret.GetBytes());
        }
        public static ByteCollection StringToByteCollection(string s, int length, char fill)
        {
            ByteCollection ret = new ByteCollection();

            if (length > 0 && length < s.Length)
            {
                ret.Add(Encoding.Default.GetBytes(s.ToCharArray(), 0, length));
            }
            else
            {
                ret.Add(Encoding.Default.GetBytes(s));
            }
            while (ret.Count < length)
            {
                ret.Add(Convert.ToByte(fill));
            }
            return(ret);
        }
 public void Add(ByteCollection bColl)
 {
     InnerList.AddRange(bColl);
     //Add(bColl.GetBytes());
 }