.net 在byte[]数组中进行Readline
来源:互联网 发布:微信生成器软件 编辑:程序博客网 时间:2024/06/12 11:08
/// <summary>
/// 返回说明:
/// string 发现一个\r\n
/// "" 有连续的\r\n
/// null 没有结束的\r\n,但缓冲区可能还有数据。
/// </summary>
public string ReadLine(System.Text.Encoding encode,bool rnFoure)
{
if (rnFoure)
{//4字节 回车换行
int toFind = 655373;
fixed (byte* p = this.Buffer)
{
byte* begin = p + this.m_Read;
int nowEnd = 0;
while (true)
{
if (nowEnd + m_Read + 4 >= m_Write)
return null;
if (toFind == (*((int*)(begin + nowEnd))))
{
int readBegin = m_Read;
m_Read = m_Read + nowEnd + 4;
return encode.GetString(Buffer, readBegin, nowEnd);
}
nowEnd++;
}
}
}
else
{//2字节 回车换行
short search = 2573;
fixed (byte* p = this.Buffer)
{
byte* begin = p + this.m_Read;
int nowEnd = 0;
while (true)
{
if (nowEnd + m_Read + 2 >= m_Write)
return null;
if (search == (*((short*)(begin + nowEnd))))
{
int readBegin = m_Read;
m_Read = m_Read + nowEnd + 2;
return encode.GetString(Buffer, readBegin, nowEnd);
}
nowEnd++;
}
}
}
/// 返回说明:
/// string 发现一个\r\n
/// "" 有连续的\r\n
/// null 没有结束的\r\n,但缓冲区可能还有数据。
/// </summary>
public string ReadLine(System.Text.Encoding encode,bool rnFoure)
{
if (rnFoure)
{//4字节 回车换行
int toFind = 655373;
fixed (byte* p = this.Buffer)
{
byte* begin = p + this.m_Read;
int nowEnd = 0;
while (true)
{
if (nowEnd + m_Read + 4 >= m_Write)
return null;
if (toFind == (*((int*)(begin + nowEnd))))
{
int readBegin = m_Read;
m_Read = m_Read + nowEnd + 4;
return encode.GetString(Buffer, readBegin, nowEnd);
}
nowEnd++;
}
}
}
else
{//2字节 回车换行
short search = 2573;
fixed (byte* p = this.Buffer)
{
byte* begin = p + this.m_Read;
int nowEnd = 0;
while (true)
{
if (nowEnd + m_Read + 2 >= m_Write)
return null;
if (search == (*((short*)(begin + nowEnd))))
{
int readBegin = m_Read;
m_Read = m_Read + nowEnd + 2;
return encode.GetString(Buffer, readBegin, nowEnd);
}
nowEnd++;
}
}
}
}
//第二次参数的获取:
public static bool IsRNFoure(System.Text.Encoding encode)
{
return encode.GetBytes("\r\n").Length == 4;
}
0 0
- .net 在byte[]数组中进行Readline
- 在byte数组中搜索byte[]
- 在Asp.Net中如何将带有中文字符的字符串转换成byte数组?
- C#.NET中string与byte数组的相互转换
- 在VB中把字符串转换成Byte数组
- 在C#中如何比较两个byte[]数组相等
- 在C#中如何比较两个byte[]数组相等
- 在java中int类型跟byte数组的转换
- 将byte[]数组转换为图片,并在jsp页面进行显示
- c++ int与byte数组进行转换
- 二分法在有序数组中进行查找
- 在数组中进行图形绘制
- [转]Java中byte数组转换int时为何与0xff进行与运算
- 在ASP.NET中进行文件处理
- 在VB.NET中进行抓屏
- 在ASP.NET中进行MD5加密。
- 解决了在Suse 10.1中导入readline提示no module named readline的问题
- c#中如何将byte数组转换成string从而在textbox中显示出来?
- 如何转换PDF文件的方法
- android 开源项目(转)
- Google Volley使用之自定义
- 为什么构造函数不能为虚函数
- Java生成MD5摘要(MD5 SHA-1)
- .net 在byte[]数组中进行Readline
- 重学JAVASE
- JS 控制VIEWPORT属性,在不同终端类型中兼容自适应显示
- Android系统dimension单位详解
- Java 异常处理
- 体绘制(Volume Rendering)概述之2:体数据详解!!!(包括下载网址)
- 虚拟机安装步骤
- poj 2955 Brackets
- Android真机调试