/// <summary> /// Encodes the character. /// </summary> /// <param name="ch">The character to encode.</param> /// <param name="outputBuffer">The output buffer.</param> /// <param name="outputBufferCount">The output buffer count.</param> /// <param name="outputEnd">The output end.</param> /// <returns> /// <c>true</c> if encoding is successful; otherwise, <c>false</c>. /// </returns> bool IFallback.FallBackChar(char ch, char[] outputBuffer, ref int outputBufferCount, int outputEnd) { if (this.htmlEscape) { HtmlEntityIndex namedEntityId = 0; if (ch <= '>') { if (ch == '>') { namedEntityId = HtmlEntityIndex.gt; } else if (ch == '<') { namedEntityId = HtmlEntityIndex.lt; } else if (ch == '&') { namedEntityId = HtmlEntityIndex.amp; } else if (ch == '\"') { namedEntityId = HtmlEntityIndex.quot; } } else if ((char)0xA0 <= ch && ch <= (char)0xFF) { namedEntityId = HtmlSupport.EntityMap[(int)ch - 0xA0]; } if ((int)namedEntityId != 0) { string strQuote = HtmlNameData.entities[(int)namedEntityId].name; if (outputEnd - outputBufferCount < strQuote.Length + 2) { return(false); } outputBuffer[outputBufferCount++] = '&'; strQuote.CopyTo(0, outputBuffer, outputBufferCount, strQuote.Length); outputBufferCount += strQuote.Length; outputBuffer[outputBufferCount++] = ';'; } else { uint value = (uint)ch; int len = (value < 0x10) ? 1 : (value < 0x100) ? 2 : (value < 0x1000) ? 3 : 4; if (outputEnd - outputBufferCount < len + 4) { return(false); } outputBuffer[outputBufferCount++] = '&'; outputBuffer[outputBufferCount++] = '#'; outputBuffer[outputBufferCount++] = 'x'; int offset = outputBufferCount + len; while (value != 0) { uint digit = value & 0xF; outputBuffer[--offset] = (char)(digit + (digit < 10 ? '0' : 'A' - 10)); value >>= 4; } outputBufferCount += len; outputBuffer[outputBufferCount++] = ';'; } } else { string substitute = AsciiEncoderFallback.GetCharacterFallback(ch); if (substitute != null) { if (outputEnd - outputBufferCount < substitute.Length) { return(false); } substitute.CopyTo(0, outputBuffer, outputBufferCount, substitute.Length); outputBufferCount += substitute.Length; } else { InternalDebug.Assert(outputEnd - outputBufferCount > 0); outputBuffer[outputBufferCount++] = ch; } } return(true); }
bool IFallback.FallBackChar(char ch, char[] outputBuffer, ref int outputBufferCount, int outputEnd) { if (literalEntities) { if (cssEscaping) { uint num = (uint)ch; int num2 = (num < 16u) ? 1 : ((num < 256u) ? 2 : ((num < 4096u) ? 3 : 4)); if (outputEnd - outputBufferCount < num2 + 2) { return(false); } outputBuffer[outputBufferCount++] = '\\'; int num3 = outputBufferCount + num2; while (num != 0u) { uint num4 = num & 15u; outputBuffer[--num3] = (char)((ulong)num4 + (ulong)((num4 < 10u) ? 48L : 55L)); num >>= 4; } outputBufferCount += num2; outputBuffer[outputBufferCount++] = ' '; } else { if (outputEnd - outputBufferCount < 1) { return(false); } outputBuffer[outputBufferCount++] = (filterHtml ? '?' : ch); } } else { HtmlEntityIndex htmlEntityIndex = (HtmlEntityIndex)0; if (ch <= '>') { if (ch == '>') { htmlEntityIndex = HtmlEntityIndex.gt; } else if (ch == '<') { htmlEntityIndex = HtmlEntityIndex.lt; } else if (ch == '&') { htmlEntityIndex = HtmlEntityIndex.amp; } else if (ch == '"') { htmlEntityIndex = HtmlEntityIndex.quot; } } else if ('\u00a0' <= ch && ch <= 'ÿ') { htmlEntityIndex = HtmlSupport.EntityMap[(int)(ch - '\u00a0')]; } if (htmlEntityIndex != (HtmlEntityIndex)0) { string name = HtmlNameData.entities[(int)htmlEntityIndex].name; if (outputEnd - outputBufferCount < name.Length + 2) { return(false); } outputBuffer[outputBufferCount++] = '&'; name.CopyTo(0, outputBuffer, outputBufferCount, name.Length); outputBufferCount += name.Length; outputBuffer[outputBufferCount++] = ';'; } else { uint num5 = (uint)ch; int num6 = (num5 < 10u) ? 1 : ((num5 < 100u) ? 2 : ((num5 < 1000u) ? 3 : ((num5 < 10000u) ? 4 : 5))); if (outputEnd - outputBufferCount < num6 + 3) { return(false); } outputBuffer[outputBufferCount++] = '&'; outputBuffer[outputBufferCount++] = '#'; int num7 = outputBufferCount + num6; while (num5 != 0u) { uint num8 = num5 % 10u; outputBuffer[--num7] = (char)(num8 + 48u); num5 /= 10u; } outputBufferCount += num6; outputBuffer[outputBufferCount++] = ';'; } } return(true); }
/// <summary> /// Encodes the character. /// </summary> /// <param name="ch">The character to encode.</param> /// <param name="outputBuffer">The output buffer.</param> /// <param name="outputBufferCount">The output buffer count.</param> /// <param name="outputEnd">The output end.</param> /// <returns> /// <c>true</c> if encoding is successful; otherwise, <c>false</c>. /// </returns> bool IFallback.FallBackChar(char ch, char[] outputBuffer, ref int outputBufferCount, int outputEnd) { if (htmlEscape) { HtmlEntityIndex htmlEntityIndex = (HtmlEntityIndex)0; if (ch <= '>') { if (ch == '>') { htmlEntityIndex = HtmlEntityIndex.gt; } else if (ch == '<') { htmlEntityIndex = HtmlEntityIndex.lt; } else if (ch == '&') { htmlEntityIndex = HtmlEntityIndex.amp; } else if (ch == '"') { htmlEntityIndex = HtmlEntityIndex.quot; } } else if ('\u00a0' <= ch && ch <= 'ÿ') { htmlEntityIndex = HtmlSupport.EntityMap[(int)(ch - '\u00a0')]; } if (htmlEntityIndex != (HtmlEntityIndex)0) { string name = HtmlNameData.entities[(int)htmlEntityIndex].name; if (outputEnd - outputBufferCount < name.Length + 2) { return(false); } outputBuffer[outputBufferCount++] = '&'; name.CopyTo(0, outputBuffer, outputBufferCount, name.Length); outputBufferCount += name.Length; outputBuffer[outputBufferCount++] = ';'; } else { uint num = (uint)ch; int num2 = (num < 16u) ? 1 : ((num < 256u) ? 2 : ((num < 4096u) ? 3 : 4)); if (outputEnd - outputBufferCount < num2 + 4) { return(false); } outputBuffer[outputBufferCount++] = '&'; outputBuffer[outputBufferCount++] = '#'; outputBuffer[outputBufferCount++] = 'x'; int num3 = outputBufferCount + num2; while (num != 0u) { uint num4 = num & 15u; outputBuffer[--num3] = (char)((ulong)num4 + (ulong)((num4 < 10u) ? 48L : 55L)); num >>= 4; } outputBufferCount += num2; outputBuffer[outputBufferCount++] = ';'; } } else { string characterFallback = AsciiEncoderFallback.GetCharacterFallback(ch); if (characterFallback != null) { if (outputEnd - outputBufferCount < characterFallback.Length) { return(false); } characterFallback.CopyTo(0, outputBuffer, outputBufferCount, characterFallback.Length); outputBufferCount += characterFallback.Length; } else { outputBuffer[outputBufferCount++] = ch; } } return(true); }
// Token: 0x060019F5 RID: 6645 RVA: 0x000CD8CC File Offset: 0x000CBACC bool IFallback.FallBackChar(char ch, char[] outputBuffer, ref int outputBufferCount, int outputEnd) { if (this.htmlEscape) { HtmlEntityIndex htmlEntityIndex = (HtmlEntityIndex)0; if (ch <= '>') { if (ch == '>') { htmlEntityIndex = HtmlEntityIndex.gt; } else if (ch == '<') { htmlEntityIndex = HtmlEntityIndex.lt; } else if (ch == '&') { htmlEntityIndex = HtmlEntityIndex.amp; } else if (ch == '"') { htmlEntityIndex = HtmlEntityIndex.quot; } } else if ('\u00a0' <= ch && ch <= 'ÿ') { htmlEntityIndex = HtmlSupport.EntityMap[(int)(ch - '\u00a0')]; } if (htmlEntityIndex != (HtmlEntityIndex)0) { string name = HtmlNameData.entities[(int)htmlEntityIndex].Name; if (outputEnd - outputBufferCount < name.Length + 2) { return false; } outputBuffer[outputBufferCount++] = '&'; name.CopyTo(0, outputBuffer, outputBufferCount, name.Length); outputBufferCount += name.Length; outputBuffer[outputBufferCount++] = ';'; } else { uint num = (uint)ch; int num2 = (num < 16U) ? 1 : ((num < 256U) ? 2 : ((num < 4096U) ? 3 : 4)); if (outputEnd - outputBufferCount < num2 + 4) { return false; } outputBuffer[outputBufferCount++] = '&'; outputBuffer[outputBufferCount++] = '#'; outputBuffer[outputBufferCount++] = 'x'; int num3 = outputBufferCount + num2; while (num != 0U) { uint num4 = num & 15U; outputBuffer[--num3] = (char)((ulong)num4 + (ulong)((num4 < 10U) ? 48L : 55L)); num >>= 4; } outputBufferCount += num2; outputBuffer[outputBufferCount++] = ';'; } } else { string substitute = TextOutput.GetSubstitute(ch); if (substitute != null) { if (outputEnd - outputBufferCount < substitute.Length) { return false; } substitute.CopyTo(0, outputBuffer, outputBufferCount, substitute.Length); outputBufferCount += substitute.Length; } else { outputBuffer[outputBufferCount++] = ch; } } return true; }
bool IFallback.FallBackChar(char ch, char[] outputBuffer, ref int outputBufferCount, int outputEnd) { if (this.literalEntities) { if (this.cssEscaping) { uint value = (uint)ch; int len = (value < 0x10) ? 1 : (value < 0x100) ? 2 : (value < 0x1000) ? 3 : 4; if (outputEnd - outputBufferCount < len + 2) { return(false); } outputBuffer[outputBufferCount++] = '\\'; int offset = outputBufferCount + len; while (value != 0) { uint digit = value & 0xF; outputBuffer[--offset] = (char)(digit + (digit < 10 ? '0' : 'A' - 10)); value >>= 4; } outputBufferCount += len; outputBuffer[outputBufferCount++] = ' '; } else { if (outputEnd - outputBufferCount < 1) { return(false); } outputBuffer[outputBufferCount++] = this.filterHtml ? '?' : ch; } } else { HtmlEntityIndex namedEntityId = 0; if (ch <= '>') { if (ch == '>') { namedEntityId = HtmlEntityIndex.gt; } else if (ch == '<') { namedEntityId = HtmlEntityIndex.lt; } else if (ch == '&') { namedEntityId = HtmlEntityIndex.amp; } else if (ch == '\"') { namedEntityId = HtmlEntityIndex.quot; } } else if ((char)0xA0 <= ch && ch <= (char)0xFF) { namedEntityId = HtmlSupport.EntityMap[(int)ch - 0xA0]; } if ((int)namedEntityId != 0) { string strQuote = HtmlNameData.entities[(int)namedEntityId].name; if (outputEnd - outputBufferCount < strQuote.Length + 2) { return(false); } outputBuffer[outputBufferCount++] = '&'; strQuote.CopyTo(0, outputBuffer, outputBufferCount, strQuote.Length); outputBufferCount += strQuote.Length; outputBuffer[outputBufferCount++] = ';'; } else { uint value = (uint)ch; int len = (value < 10) ? 1 : (value < 100) ? 2 : (value < 1000) ? 3 : (value < 10000) ? 4 : 5; if (outputEnd - outputBufferCount < len + 3) { return(false); } outputBuffer[outputBufferCount++] = '&'; outputBuffer[outputBufferCount++] = '#'; int offset = outputBufferCount + len; while (value != 0) { uint digit = value % 10; outputBuffer[--offset] = (char)(digit + '0'); value /= 10; } outputBufferCount += len; outputBuffer[outputBufferCount++] = ';'; } } return(true); }