📄 htmlstream.cs
字号:
for (char ch1 = this.buffer[this.pos]; (this.pos < this.used) && (ch1 != what); ch1 = this.buffer[++this.pos])
{
}
}
internal void SkipWhitespace()
{
for (char ch1 = this.buffer[this.pos]; (this.pos < this.used) && (((ch1 == ' ') || (ch1 == '\r')) || (ch1 == '\n')); ch1 = this.buffer[++this.pos])
{
}
}
private string SniffAttribute(string name)
{
this.SniffWhitespace();
string text1 = this.SniffName();
if (name == text1)
{
this.SniffWhitespace();
if (this.SniffPattern("="))
{
this.SniffWhitespace();
return this.SniffLiteral();
}
}
return null;
}
private string SniffAttribute(out string name)
{
this.SniffWhitespace();
name = this.SniffName();
if (name != null)
{
this.SniffWhitespace();
if (this.SniffPattern("="))
{
this.SniffWhitespace();
return this.SniffLiteral();
}
}
return null;
}
internal System.Text.Decoder SniffEncoding()
{
System.Text.Decoder decoder1 = null;
if (this.SniffPattern("<?xml"))
{
string text1 = this.SniffAttribute("version");
if (text1 != null)
{
string text2 = this.SniffAttribute("encoding");
if (text2 != null)
{
try
{
System.Text.Encoding encoding1 = System.Text.Encoding.GetEncoding(text2);
if (encoding1 != null)
{
this.encoding = encoding1;
return encoding1.GetDecoder();
}
}
catch (Exception)
{
}
}
this.SniffTerminator(">");
}
}
if (decoder1 == null)
{
return this.SniffMeta();
}
return null;
}
private string SniffLiteral()
{
int num1 = this.PeekChar();
if ((num1 == 0x27) || (num1 == 0x22))
{
this.ReadChar();
int num2 = this.pos;
for (int num3 = this.ReadChar(); (num3 != -1) && (num3 != num1); num3 = this.ReadChar())
{
}
return ((this.pos > num2) ? new string(this.buffer, num2, (this.pos - num2) - 1) : "");
}
return null;
}
internal System.Text.Decoder SniffMeta()
{
for (int num1 = this.ReadChar(); num1 != -1; num1 = this.ReadChar())
{
string text4;
bool flag1;
char ch1 = (char) ((ushort) num1);
if (ch1 != '<')
{
goto Label_017B;
}
string text1 = this.SniffName();
if ((text1 == null) || (text1.ToLower() != "meta"))
{
goto Label_017A;
}
string text2 = null;
string text3 = null;
goto Label_00AC;
Label_0054:
text4 = this.SniffAttribute(out text1);
if (text1 == null)
{
goto Label_00B1;
}
switch (text1.ToLower())
{
case "http-equiv":
text2 = text4;
break;
case "content":
text3 = text4;
break;
}
Label_00AC:
flag1 = true;
goto Label_0054;
Label_00B1:
if (((text2 != null) && (text2.ToLower() == "content-type")) && (text3 != null))
{
int num2 = text3.IndexOf("charset");
if (num2 >= 0)
{
num2 = text3.IndexOf("=", num2);
if (num2 >= 0)
{
num2++;
int num3 = text3.IndexOf(";", num2);
if (num3 < 0)
{
num3 = text3.Length;
}
string text5 = text3.Substring(num2, num3 - num2).Trim();
try
{
System.Text.Encoding encoding1 = System.Text.Encoding.GetEncoding(text5);
this.encoding = encoding1;
return encoding1.GetDecoder();
}
catch
{
}
}
}
}
Label_017A:;
Label_017B:;
}
return null;
}
internal string SniffName()
{
if (this.pos == this.used)
{
return null;
}
char ch1 = this.buffer[this.pos];
int num1 = this.pos;
while ((this.pos < this.used) && (((char.IsLetterOrDigit(ch1) || (ch1 == '-')) || (ch1 == '_')) || (ch1 == ':')))
{
ch1 = this.buffer[++this.pos];
}
if (num1 == this.pos)
{
return null;
}
return new string(this.buffer, num1, this.pos - num1);
}
private bool SniffPattern(string pattern)
{
int num1 = this.PeekChar();
if (num1 != pattern[0])
{
return false;
}
int num2 = 0;
int num3 = pattern.Length;
while ((num1 != -1) && (num2 < num3))
{
num1 = this.ReadChar();
char ch1 = pattern[num2];
if (num1 != ch1)
{
return false;
}
num2++;
}
return true;
}
private void SniffTerminator(string term)
{
int num1 = this.ReadChar();
int num2 = 0;
int num3 = term.Length;
while ((num2 < num3) && (num1 != -1))
{
if (term[num2] == num1)
{
num2++;
if (num2 == num3)
{
return;
}
}
else
{
num2 = 0;
}
num1 = this.ReadChar();
}
}
private void SniffWhitespace()
{
char ch1 = (char) ((ushort) this.PeekChar());
while ((((ch1 == ' ') || (ch1 == '\r')) || (ch1 == '\r')) || (ch1 == '\n'))
{
int num1 = this.pos;
ch1 = (char) ((ushort) this.ReadChar());
if ((((ch1 != ' ') && (ch1 != '\r')) && (ch1 != '\r')) && (ch1 != '\n'))
{
this.pos = num1;
}
}
}
public System.Text.Encoding Encoding
{
get
{
return this.encoding;
}
}
private char[] buffer;
private const int BUFSIZE = 0x4000;
private System.Text.Decoder decoder;
private System.Text.Encoding encoding;
private const int EOF = -1;
private int pos;
private byte[] rawBuffer;
private int rawPos;
private int rawUsed;
private Stream stm;
private int used;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -