⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmessage.encode.txt

📁 基予GPRS modem
💻 TXT
字号:
       private byte[] encodeUintvar(int n)
        {
            byte[] buf = new byte[8];
            int l = 0;
            while (n >= 128)
            {
                byte b = (byte)(n & 0x7F);
                n = n >> 7;
                buf[l++] = b;
            }
            buf[l++] = (byte)n;

            byte[] retBys = new byte[l];
            for (int i = 0; i < l; ++i)
            {
                retBys[i] = (byte)(buf[l - i - 1] | 0x80);
            }
            retBys[l - 1] &= 0x7F;
            return retBys;

        }
        //   从文件中读取字节   
        private byte[] ReadFromFile(string FileName)
        {
            byte[] bf = new byte[0];
            FileStream fs = null;
            try
            {
                fs = new FileStream(FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.None);     //   没有设定Buffsize   
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            if (fs != null)
            {
                bf = new byte[fs.Length];
                fs.Read(bf, 0, (int)fs.Length);
                fs.Close();
            }
            return bf;
        }
        //   得到文件名(不包含文件夹部分)   
        private string getContentId(string FileName)
        {
            int at = FileName.LastIndexOf("\\");
            if (at < 0)
                return FileName;
            else
                return FileName.Substring(at + 1);
        }
        //   增加字节   
        private byte[] AppendOct(byte[] bys, byte[] byDest)
        {
            byte[] bysNew = new byte[byDest.Length + bys.Length];
            try
            {
                Array.Copy(byDest, bysNew, byDest.Length);
                Array.Copy(bys, 0, bysNew, byDest.Length, bys.Length);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return bysNew;
        }
        //   增加字符串   
        private byte[] AppendOct(string sz, byte[] byDest)
        {
            return AppendOct(Encoding.Default.GetBytes(sz), byDest);
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -