本文整理汇总了C#中System.Char.IsSpaceCharacter方法的典型用法代码示例。如果您正苦于以下问题:C# Char.IsSpaceCharacter方法的具体用法?C# Char.IsSpaceCharacter怎么用?C# Char.IsSpaceCharacter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Char
的用法示例。
在下文中一共展示了Char.IsSpaceCharacter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessingTarget
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#sec-pi.
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="pi">The processing instruction token.</param>
protected XmlToken ProcessingTarget(Char c, XmlPIToken pi)
{
while (true)
{
if (c.IsSpaceCharacter())
{
pi.Target = _stringBuffer.ToString();
_stringBuffer.Clear();
return ProcessingContent(_src.Next, pi);
}
else if (c == Specification.QM)
{
pi.Target = _stringBuffer.ToString();
_stringBuffer.Clear();
return ProcessingContent(c, pi);
}
else if (c == Specification.NULL)
{
RaiseErrorOccurred(ErrorCode.NULL);
c = Specification.REPLACEMENT;
}
else if (c == Specification.EOF)
{
RaiseErrorOccurred(ErrorCode.EOF);
return XmlToken.EOF;
}
_stringBuffer.Append(c);
c = _src.Next;
}
}
示例2: AttributeDeclaration
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#attdecls.
/// </summary>
/// <param name="c">The next input character.</param>
DtdAttributeToken AttributeDeclaration(Char c)
{
var decl = new DtdAttributeToken();
var canContinue = false;
if (c.IsSpaceCharacter())
canContinue = DeclarationNameBefore(_src.Next, decl);
else if (c == Specification.EOF)
throw new ArgumentException("The document ended unexpectedly.");
else
{
RaiseErrorOccurred(ErrorCode.UndefinedMarkupDeclaration);
canContinue = DeclarationNameBefore(c, decl);
}
c = _src.Current;
if (canContinue)
{
while (true)
{
while (c.IsSpaceCharacter())
c = _src.Next;
if (c.IsNameStart())
{
_stringBuffer.Clear();
decl.Attributes.Add(AttributeDeclarationName(c));
c = _src.Current;
continue;
}
break;
}
}
return AttributeDeclarationAfter(c, decl);
}
示例3: AttributeName
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#NT-Attribute.
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="tag">The current tag token.</param>
XmlToken AttributeName(Char c, XmlTagToken tag)
{
while (c.IsXmlName())
{
_stringBuffer.Append(c);
c = GetNext();
}
var name = FlushBuffer();
if (!String.IsNullOrEmpty(tag.GetAttribute(name)))
throw XmlParseError.XmlUniqueAttribute.At(GetCurrentPosition());
tag.AddAttribute(name);
if (c.IsSpaceCharacter())
{
do c = GetNext();
while (c.IsSpaceCharacter());
}
if (c == Symbols.Equality)
return AttributeBeforeValue(GetNext(), tag);
throw XmlParseError.XmlInvalidAttribute.At(GetCurrentPosition());
}
示例4: DoctypeAfter
/// <summary>
/// The doctype finalizer.
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="doctype">The current doctype token.</param>
/// <returns>The emitted token.</returns>
XmlToken DoctypeAfter(Char c, XmlDoctypeToken doctype)
{
while (c.IsSpaceCharacter())
c = GetNext();
if (c == Symbols.GreaterThan)
return doctype;
throw XmlParseError.DoctypeInvalid.At(GetCurrentPosition());
}
示例5: DoctypeSystem
/// <summary>
/// See 8.2.4.62 After DOCTYPE system keyword state
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="doctype">The current doctype token.</param>
/// <returns>The emitted token.</returns>
XmlToken DoctypeSystem(Char c, XmlDoctypeToken doctype)
{
if (c.IsSpaceCharacter())
{
while (c.IsSpaceCharacter())
c = GetNext();
if (c == Symbols.DoubleQuote || c == Symbols.SingleQuote)
{
doctype.SystemIdentifier = String.Empty;
return DoctypeSystemIdentifierValue(GetNext(), c, doctype);
}
}
throw XmlParseError.DoctypeInvalid.At(GetCurrentPosition());
}
示例6: DoctypeNameAfter
/// <summary>
/// See 8.2.4.55 After DOCTYPE name state
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="doctype">The current doctype token.</param>
/// <returns>The emitted token.</returns>
XmlToken DoctypeNameAfter(Char c, XmlDoctypeToken doctype)
{
while (c.IsSpaceCharacter())
c = GetNext();
if (c == Symbols.GreaterThan)
return doctype;
if (ContinuesWithSensitive(Keywords.Public))
{
Advance(5);
return DoctypePublic(GetNext(), doctype);
}
else if (ContinuesWithSensitive(Keywords.System))
{
Advance(5);
return DoctypeSystem(GetNext(), doctype);
}
else if (c == Symbols.SquareBracketOpen)
{
Advance();
return DoctypeAfter(GetNext(), doctype);
}
throw XmlParseError.DoctypeInvalid.At(GetCurrentPosition());
}
示例7: DoctypeNameBefore
/// <summary>
/// See 8.2.4.53 Before DOCTYPE name state
/// </summary>
/// <param name="c">The next input character.</param>
XmlToken DoctypeNameBefore(Char c)
{
while (c.IsSpaceCharacter())
c = GetNext();
if (c.IsXmlNameStart())
{
_stringBuffer.Append(c);
return DoctypeName(GetNext(), NewDoctype());
}
throw XmlParseError.DoctypeInvalid.At(GetCurrentPosition());
}
示例8: DeclarationEnd
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#NT-XMLDecl.
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="decl">The current declaration token.</param>
XmlDeclarationToken DeclarationEnd(Char c, XmlDeclarationToken decl)
{
while (c.IsSpaceCharacter())
c = GetNext();
if (c != Symbols.QuestionMark || GetNext() != Symbols.GreaterThan)
throw XmlParseError.XmlDeclarationInvalid.At(GetCurrentPosition());
return decl;
}
示例9: AttributeAfterValue
/// <summary>
/// More http://www.w3.org/TR/REC-xml/#NT-Attribute.
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="tag">The current tag token.</param>
XmlToken AttributeAfterValue(Char c, XmlTagToken tag)
{
if (c.IsSpaceCharacter())
return AttributeBeforeName(GetNext(), tag);
else if (c == Symbols.Solidus)
return TagSelfClosing(GetNext(), tag);
else if (c == Symbols.GreaterThan)
return tag;
throw XmlParseError.XmlInvalidAttribute.At(GetCurrentPosition());
}
示例10: Doctype
/// <summary>
/// See 8.2.4.52 DOCTYPE state
/// </summary>
/// <param name="c">The next input character.</param>
HtmlToken Doctype(Char c)
{
if (c.IsSpaceCharacter())
{
return DoctypeNameBefore(GetNext());
}
else if (c == Symbols.EndOfFile)
{
RaiseErrorOccurred(HtmlParseError.EOF);
Back();
return NewDoctype(true);
}
else
{
RaiseErrorOccurred(HtmlParseError.DoctypeUnexpected);
return DoctypeNameBefore(c);
}
}
示例11: AppendCharacterReference
/// <summary>
/// See 8.2.4.69 Tokenizing character references
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="allowedCharacter">The additionally allowed character if there is one.</param>
void AppendCharacterReference(Char c, Char allowedCharacter = Symbols.Null)
{
if (c.IsSpaceCharacter() || c == Symbols.LessThan || c == Symbols.EndOfFile || c == Symbols.Ampersand || c == allowedCharacter)
{
Back();
_stringBuffer.Append(Symbols.Ampersand);
return;
}
var entity = default(String);
if (c == Symbols.Num)
{
var exp = 10;
var basis = 1;
var num = 0;
var nums = new List<Int32>();
c = GetNext();
var isHex = c == 'x' || c == 'X';
if (isHex)
{
exp = 16;
while ((c = GetNext()).IsHex())
nums.Add(c.FromHex());
}
else
{
while (c.IsDigit())
{
nums.Add(c.FromHex());
c = GetNext();
}
}
for (var i = nums.Count - 1; i >= 0; i--)
{
num += nums[i] * basis;
basis *= exp;
}
if (nums.Count == 0)
{
Back(2);
if (isHex)
Back();
RaiseErrorOccurred(HtmlParseError.CharacterReferenceWrongNumber);
_stringBuffer.Append(Symbols.Ampersand);
return;
}
if (c != Symbols.Semicolon)
{
RaiseErrorOccurred(HtmlParseError.CharacterReferenceSemicolonMissing);
Back();
}
if (Entities.IsInCharacterTable(num))
{
RaiseErrorOccurred(HtmlParseError.CharacterReferenceInvalidCode);
entity = Entities.GetSymbolFromTable(num);
}
else if (Entities.IsInvalidNumber(num))
{
RaiseErrorOccurred(HtmlParseError.CharacterReferenceInvalidNumber);
entity = Symbols.Replacement.ToString();
}
else
{
if (Entities.IsInInvalidRange(num))
RaiseErrorOccurred(HtmlParseError.CharacterReferenceInvalidRange);
entity = Entities.Convert(num);
}
}
else
{
var consumed = 0;
var start = InsertionPoint - 1;
var reference = new Char[31];
var index = 0;
var chr = Current;
do
{
if (chr == Symbols.Semicolon || !chr.IsName())
break;
reference[index++] = chr;
var value = new String(reference, 0, index);
chr = GetNext();
consumed++;
//.........这里部分代码省略.........
示例12: CreateIfAppropriate
HtmlToken CreateIfAppropriate(Char c)
{
var isspace = c.IsSpaceCharacter();
var isclosed = c == Symbols.GreaterThan;
var isslash = c == Symbols.Solidus;
var hasLength = _stringBuffer.Length == _lastStartTag.Length;
if (hasLength && (isspace || isclosed || isslash) &&
_stringBuffer.ToString().Equals(_lastStartTag, StringComparison.Ordinal))
{
var tag = NewTagClose();
_stringBuffer.Clear();
if (isspace)
{
tag.Name = _lastStartTag;
return AttributeBeforeName(tag);
}
else if (isslash)
{
tag.Name = _lastStartTag;
return TagSelfClosing(tag);
}
else if (isclosed)
{
tag.Name = _lastStartTag;
return EmitTag(tag);
}
}
return null;
}
示例13: AttributeUnquotedValue
/// <summary>
/// See 8.2.4.40 Attribute value (unquoted) state
/// </summary>
/// <param name="c">The next input character.</param>
/// <param name="tag">The current tag token.</param>
HtmlToken AttributeUnquotedValue(Char c, HtmlTagToken tag)
{
while (true)
{
if (c == Symbols.GreaterThan)
{
tag.SetAttributeValue(_stringBuffer.ToString());
_stringBuffer.Clear();
return EmitTag(tag);
}
else if (c.IsSpaceCharacter())
{
tag.SetAttributeValue(_stringBuffer.ToString());
_stringBuffer.Clear();
return AttributeBeforeName(tag);
}
else if (c == Symbols.Ampersand)
{
AppendCharacterReference(GetNext(), Symbols.GreaterThan);
}
else if (c == Symbols.Null)
{
RaiseErrorOccurred(HtmlParseError.Null);
_stringBuffer.Append(Symbols.Replacement);
}
else if (c == Symbols.DoubleQuote || c == Symbols.SingleQuote || c == Symbols.LessThan || c == Symbols.Equality || c == Symbols.CurvedQuote)
{
RaiseErrorOccurred(HtmlParseError.AttributeValueInvalid);
_stringBuffer.Append(c);
}
else if (c != Symbols.EndOfFile)
{
_stringBuffer.Append(c);
}
else
{
return NewEof();
}
c = GetNext();
}
}
示例14: DoctypeNameBefore
/// <summary>
/// See 8.2.4.53 Before DOCTYPE name state
/// </summary>
/// <param name="c">The next input character.</param>
HtmlToken DoctypeNameBefore(Char c)
{
while (c.IsSpaceCharacter())
c = GetNext();
if (c.IsUppercaseAscii())
{
var doctype = NewDoctype(false);
_stringBuffer.Append(Char.ToLower(c));
return DoctypeName(doctype);
}
else if (c == Symbols.Null)
{
var doctype = NewDoctype(false);
RaiseErrorOccurred(HtmlParseError.Null);
_stringBuffer.Append(Symbols.Replacement);
return DoctypeName(doctype);
}
else if (c == Symbols.GreaterThan)
{
var doctype = NewDoctype(true);
_state = HtmlParseMode.PCData;
RaiseErrorOccurred(HtmlParseError.TagClosedWrong);
return doctype;
}
else if (c == Symbols.EndOfFile)
{
var doctype = NewDoctype(true);
RaiseErrorOccurred(HtmlParseError.EOF);
Back();
return doctype;
}
else
{
var doctype = NewDoctype(false);
_stringBuffer.Append(c);
return DoctypeName(doctype);
}
}
示例15: TransformFunctionWhitespace
/// <summary>
/// 4.4.11. Transform-function-whitespace state
/// </summary>
CssToken TransformFunctionWhitespace(Char current)
{
while (true)
{
current = Next;
if (current == Specification.RoundBracketOpen)
{
Back();
return CssKeywordToken.Function(FlushBuffer());
}
else if (!current.IsSpaceCharacter())
{
Back(2);
return CssKeywordToken.Ident(FlushBuffer());
}
}
}