Files
Dec2017-Script-Dump/mscorlib/System/Text/ASCIIEncoding.cs
T
2026-06-04 11:42:34 +02:00

601 lines
29 KiB
C#

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.Text
{
/// <summary>Represents an ASCII character encoding of Unicode characters.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x020005DE RID: 1502
[ComVisible(true)]
[MonoTODO("Serialization format not compatible with .NET")]
[Serializable]
public class ASCIIEncoding : Encoding
{
/// <summary>Initializes a new instance of the <see cref="T:System.Text.ASCIIEncoding" /> class.</summary>
// Token: 0x060036B6 RID: 14006 RVA: 0x000BB950 File Offset: 0x000B9B50
public ASCIIEncoding()
: base(20127)
{
this.body_name = (this.header_name = (this.web_name = "us-ascii"));
this.encoding_name = "US-ASCII";
this.is_mail_news_display = true;
this.is_mail_news_save = true;
}
/// <summary>Gets a value indicating whether the current encoding uses single-byte code points.</summary>
/// <returns>This property is always true.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x17000AB4 RID: 2740
// (get) Token: 0x060036B7 RID: 14007 RVA: 0x000BB9A0 File Offset: 0x000B9BA0
[ComVisible(false)]
public override bool IsSingleByte
{
get
{
return true;
}
}
/// <summary>Calculates the number of bytes produced by encoding a set of characters from the specified character array.</summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="chars" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> or <paramref name="count" /> is less than zero.-or- <paramref name="index" /> and <paramref name="count" /> do not denote a valid range in <paramref name="chars" />.-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer. </exception>
/// <exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (see Understanding Encodings for complete explanation)-and-<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036B8 RID: 14008 RVA: 0x000BB9A4 File Offset: 0x000B9BA4
public override int GetByteCount(char[] chars, int index, int count)
{
if (chars == null)
{
throw new ArgumentNullException("chars");
}
if (index < 0 || index > chars.Length)
{
throw new ArgumentOutOfRangeException("index", Encoding._("ArgRange_Array"));
}
if (count < 0 || count > chars.Length - index)
{
throw new ArgumentOutOfRangeException("count", Encoding._("ArgRange_Array"));
}
return count;
}
/// <summary>Calculates the number of bytes produced by encoding the characters in the specified <see cref="T:System.String" />.</summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="chars">The <see cref="T:System.String" /> containing the set of characters to encode.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="chars" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">The resulting number of bytes is greater than the maximum number that can be returned as an integer. </exception>
/// <exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (see Understanding Encodings for complete explanation)-and-<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036B9 RID: 14009 RVA: 0x000BBA10 File Offset: 0x000B9C10
public override int GetByteCount(string chars)
{
if (chars == null)
{
throw new ArgumentNullException("chars");
}
return chars.Length;
}
/// <summary>Encodes a set of characters from the specified character array into the specified byte array.</summary>
/// <returns>The actual number of bytes written into <paramref name="bytes" />.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="chars" /> is null.-or- <paramref name="bytes" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="charIndex" /> or <paramref name="charCount" /> or <paramref name="byteIndex" /> is less than zero.-or- <paramref name="charIndex" /> and <paramref name="charCount" /> do not denote a valid range in <paramref name="chars" />.-or- <paramref name="byteIndex" /> is not a valid index in <paramref name="bytes" />. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="bytes" /> does not have enough capacity from <paramref name="byteIndex" /> to the end of the array to accommodate the resulting bytes. </exception>
/// <exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (see Understanding Encodings for complete explanation)-and-<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036BA RID: 14010 RVA: 0x000BBA2C File Offset: 0x000B9C2C
public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
EncoderFallbackBuffer encoderFallbackBuffer = null;
char[] array = null;
return this.GetBytes(chars, charIndex, charCount, bytes, byteIndex, ref encoderFallbackBuffer, ref array);
}
// Token: 0x060036BB RID: 14011 RVA: 0x000BBA50 File Offset: 0x000B9C50
private int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, ref EncoderFallbackBuffer buffer, ref char[] fallback_chars)
{
if (chars == null)
{
throw new ArgumentNullException("chars");
}
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (charIndex < 0 || charIndex > chars.Length)
{
throw new ArgumentOutOfRangeException("charIndex", Encoding._("ArgRange_Array"));
}
if (charCount < 0 || charCount > chars.Length - charIndex)
{
throw new ArgumentOutOfRangeException("charCount", Encoding._("ArgRange_Array"));
}
if (byteIndex < 0 || byteIndex > bytes.Length)
{
throw new ArgumentOutOfRangeException("byteIndex", Encoding._("ArgRange_Array"));
}
if (bytes.Length - byteIndex < charCount)
{
throw new ArgumentException(Encoding._("Arg_InsufficientSpace"));
}
int num = charCount;
while (num-- > 0)
{
char c = chars[charIndex++];
if (c < '\u0080')
{
bytes[byteIndex++] = (byte)c;
}
else
{
if (buffer == null)
{
buffer = base.EncoderFallback.CreateFallbackBuffer();
}
if (char.IsSurrogate(c) && num > 1 && char.IsSurrogate(chars[charIndex]))
{
buffer.Fallback(c, chars[charIndex], charIndex++ - 1);
}
else
{
buffer.Fallback(c, charIndex - 1);
}
if (fallback_chars == null || fallback_chars.Length < buffer.Remaining)
{
fallback_chars = new char[buffer.Remaining];
}
for (int i = 0; i < fallback_chars.Length; i++)
{
fallback_chars[i] = buffer.GetNextChar();
}
byteIndex += this.GetBytes(fallback_chars, 0, fallback_chars.Length, bytes, byteIndex, ref buffer, ref fallback_chars);
}
}
return charCount;
}
/// <summary>Encodes a set of characters from the specified <see cref="T:System.String" /> into the specified byte array.</summary>
/// <returns>The actual number of bytes written into <paramref name="bytes" />.</returns>
/// <param name="chars">The <see cref="T:System.String" /> containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="s" /> is null.-or- <paramref name="bytes" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="charIndex" /> or <paramref name="charCount" /> or <paramref name="byteIndex" /> is less than zero.-or- <paramref name="charIndex" /> and <paramref name="charCount" /> do not denote a valid range in <paramref name="chars" />.-or- <paramref name="byteIndex" /> is not a valid index in <paramref name="bytes" />. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="bytes" /> does not have enough capacity from <paramref name="byteIndex" /> to the end of the array to accommodate the resulting bytes. </exception>
/// <exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (see Understanding Encodings for complete explanation)-and-<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036BC RID: 14012 RVA: 0x000BBC10 File Offset: 0x000B9E10
public override int GetBytes(string chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
EncoderFallbackBuffer encoderFallbackBuffer = null;
char[] array = null;
return this.GetBytes(chars, charIndex, charCount, bytes, byteIndex, ref encoderFallbackBuffer, ref array);
}
// Token: 0x060036BD RID: 14013 RVA: 0x000BBC34 File Offset: 0x000B9E34
private int GetBytes(string chars, int charIndex, int charCount, byte[] bytes, int byteIndex, ref EncoderFallbackBuffer buffer, ref char[] fallback_chars)
{
if (chars == null)
{
throw new ArgumentNullException("chars");
}
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (charIndex < 0 || charIndex > chars.Length)
{
throw new ArgumentOutOfRangeException("charIndex", Encoding._("ArgRange_StringIndex"));
}
if (charCount < 0 || charCount > chars.Length - charIndex)
{
throw new ArgumentOutOfRangeException("charCount", Encoding._("ArgRange_StringRange"));
}
if (byteIndex < 0 || byteIndex > bytes.Length)
{
throw new ArgumentOutOfRangeException("byteIndex", Encoding._("ArgRange_Array"));
}
if (bytes.Length - byteIndex < charCount)
{
throw new ArgumentException(Encoding._("Arg_InsufficientSpace"));
}
int num = charCount;
while (num-- > 0)
{
char c = chars[charIndex++];
if (c < '\u0080')
{
bytes[byteIndex++] = (byte)c;
}
else
{
if (buffer == null)
{
buffer = base.EncoderFallback.CreateFallbackBuffer();
}
if (char.IsSurrogate(c) && num > 1 && char.IsSurrogate(chars[charIndex]))
{
buffer.Fallback(c, chars[charIndex], charIndex++ - 1);
}
else
{
buffer.Fallback(c, charIndex - 1);
}
if (fallback_chars == null || fallback_chars.Length < buffer.Remaining)
{
fallback_chars = new char[buffer.Remaining];
}
for (int i = 0; i < fallback_chars.Length; i++)
{
fallback_chars[i] = buffer.GetNextChar();
}
byteIndex += this.GetBytes(fallback_chars, 0, fallback_chars.Length, bytes, byteIndex, ref buffer, ref fallback_chars);
}
}
return charCount;
}
/// <summary>Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.</summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="bytes" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> or <paramref name="count" /> is less than zero.-or- <paramref name="index" /> and <paramref name="count" /> do not denote a valid range in <paramref name="bytes" />.-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer. </exception>
/// <exception cref="T:System.Text.DecoderFallbackException">A fallback occurred (see Understanding Encodings for complete explanation)-and-<see cref="P:System.Text.Encoding.DecoderFallback" /> is set to <see cref="T:System.Text.DecoderExceptionFallback" />.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036BE RID: 14014 RVA: 0x000BBE04 File Offset: 0x000BA004
public override int GetCharCount(byte[] bytes, int index, int count)
{
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (index < 0 || index > bytes.Length)
{
throw new ArgumentOutOfRangeException("index", Encoding._("ArgRange_Array"));
}
if (count < 0 || count > bytes.Length - index)
{
throw new ArgumentOutOfRangeException("count", Encoding._("ArgRange_Array"));
}
return count;
}
/// <summary>Decodes a sequence of bytes from the specified byte array into the specified character array.</summary>
/// <returns>The actual number of characters written into <paramref name="chars" />.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="byteIndex">The index of the first byte to decode.</param>
/// <param name="byteCount">The number of bytes to decode.</param>
/// <param name="chars">The character array to contain the resulting set of characters.</param>
/// <param name="charIndex">The index at which to start writing the resulting set of characters.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="bytes" /> is null.-or- <paramref name="chars" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="byteIndex" /> or <paramref name="byteCount" /> or <paramref name="charIndex" /> is less than zero.-or- <paramref name="byteindex" /> and <paramref name="byteCount" /> do not denote a valid range in <paramref name="bytes" />.-or- <paramref name="charIndex" /> is not a valid index in <paramref name="chars" />. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="chars" /> does not have enough capacity from <paramref name="charIndex" /> to the end of the array to accommodate the resulting characters. </exception>
/// <exception cref="T:System.Text.DecoderFallbackException">A fallback occurred (see Understanding Encodings for complete explanation)-and-<see cref="P:System.Text.Encoding.DecoderFallback" /> is set to <see cref="T:System.Text.DecoderExceptionFallback" />.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036BF RID: 14015 RVA: 0x000BBE70 File Offset: 0x000BA070
public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
{
DecoderFallbackBuffer decoderFallbackBuffer = null;
return this.GetChars(bytes, byteIndex, byteCount, chars, charIndex, ref decoderFallbackBuffer);
}
// Token: 0x060036C0 RID: 14016 RVA: 0x000BBE90 File Offset: 0x000BA090
private int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, ref DecoderFallbackBuffer buffer)
{
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (chars == null)
{
throw new ArgumentNullException("chars");
}
if (byteIndex < 0 || byteIndex > bytes.Length)
{
throw new ArgumentOutOfRangeException("byteIndex", Encoding._("ArgRange_Array"));
}
if (byteCount < 0 || byteCount > bytes.Length - byteIndex)
{
throw new ArgumentOutOfRangeException("byteCount", Encoding._("ArgRange_Array"));
}
if (charIndex < 0 || charIndex > chars.Length)
{
throw new ArgumentOutOfRangeException("charIndex", Encoding._("ArgRange_Array"));
}
if (chars.Length - charIndex < byteCount)
{
throw new ArgumentException(Encoding._("Arg_InsufficientSpace"));
}
int num = byteCount;
while (num-- > 0)
{
char c = (char)bytes[byteIndex++];
if (c < '\u0080')
{
chars[charIndex++] = c;
}
else
{
if (buffer == null)
{
buffer = base.DecoderFallback.CreateFallbackBuffer();
}
buffer.Fallback(bytes, byteIndex);
while (buffer.Remaining > 0)
{
chars[charIndex++] = buffer.GetNextChar();
}
}
}
return byteCount;
}
/// <summary>Calculates the maximum number of bytes produced by encoding the specified number of characters.</summary>
/// <returns>The maximum number of bytes produced by encoding the specified number of characters.</returns>
/// <param name="charCount">The number of characters to encode.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="charCount" /> is less than zero.-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036C1 RID: 14017 RVA: 0x000BBFD0 File Offset: 0x000BA1D0
public override int GetMaxByteCount(int charCount)
{
if (charCount < 0)
{
throw new ArgumentOutOfRangeException("charCount", Encoding._("ArgRange_NonNegative"));
}
return charCount;
}
/// <summary>Calculates the maximum number of characters produced by decoding the specified number of bytes.</summary>
/// <returns>The maximum number of characters produced by decoding the specified number of bytes.</returns>
/// <param name="byteCount">The number of bytes to decode.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="byteCount" /> is less than zero.-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036C2 RID: 14018 RVA: 0x000BBFF0 File Offset: 0x000BA1F0
public override int GetMaxCharCount(int byteCount)
{
if (byteCount < 0)
{
throw new ArgumentOutOfRangeException("byteCount", Encoding._("ArgRange_NonNegative"));
}
return byteCount;
}
/// <summary>Decodes a range of bytes from a byte array into a string.</summary>
/// <returns>A <see cref="T:System.String" /> containing the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="byteIndex">The index of the first byte to decode.</param>
/// <param name="byteCount">The number of bytes to decode.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="bytes" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> or <paramref name="count" /> is less than zero.-or- <paramref name="index" /> and <paramref name="count" /> do not denote a valid range in <paramref name="bytes" />. </exception>
/// <exception cref="T:System.Text.DecoderFallbackException">A fallback occurred (see Understanding Encodings for complete explanation)-and-<see cref="P:System.Text.Encoding.DecoderFallback" /> is set to <see cref="T:System.Text.DecoderExceptionFallback" />.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036C3 RID: 14019 RVA: 0x000BC010 File Offset: 0x000BA210
public unsafe override string GetString(byte[] bytes, int byteIndex, int byteCount)
{
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (byteIndex < 0 || byteIndex > bytes.Length)
{
throw new ArgumentOutOfRangeException("byteIndex", Encoding._("ArgRange_Array"));
}
if (byteCount < 0 || byteCount > bytes.Length - byteIndex)
{
throw new ArgumentOutOfRangeException("byteCount", Encoding._("ArgRange_Array"));
}
if (byteCount == 0)
{
return string.Empty;
}
fixed (byte* ptr = (ref bytes != null && bytes.Length != 0 ? ref bytes[0] : ref *null))
{
string text = string.InternalAllocateStr(byteCount);
fixed (string text2 = text)
{
fixed (char* ptr2 = text2 + RuntimeHelpers.OffsetToStringData / 2)
{
byte* ptr3 = ptr + byteIndex;
byte* ptr4 = ptr3 + byteCount;
char* ptr5 = ptr2;
while (ptr3 < ptr4)
{
byte b = *(ptr3++);
*(ptr5++) = ((b > 127) ? '?' : ((char)b));
}
text2 = null;
return text;
}
}
}
}
/// <summary>Encodes a set of characters starting at the specified character pointer into a sequence of bytes that are stored starting at the specified byte pointer.</summary>
/// <returns>The actual number of bytes written at the location indicated by <paramref name="bytes" />.</returns>
/// <param name="chars">A pointer to the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">A pointer to the location at which to start writing the resulting sequence of bytes.</param>
/// <param name="byteCount">The maximum number of bytes to write.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="chars" /> is null.-or- <paramref name="bytes" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="charCount" /> or <paramref name="byteCount" /> is less than zero. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="byteCount" /> is less than the resulting number of bytes. </exception>
/// <exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (see Understanding Encodings for complete explanation)-and-<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036C4 RID: 14020 RVA: 0x000BC0FC File Offset: 0x000BA2FC
[CLSCompliant(false)]
[ComVisible(false)]
public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
{
if (chars == null)
{
throw new ArgumentNullException("chars");
}
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (charCount < 0)
{
throw new ArgumentOutOfRangeException("charCount");
}
if (byteCount < 0)
{
throw new ArgumentOutOfRangeException("byteCount");
}
if (byteCount < charCount)
{
throw new ArgumentException("bytecount is less than the number of bytes required", "byteCount");
}
for (int i = 0; i < charCount; i++)
{
char c = chars[i];
bytes[i] = (byte)((c >= '\u0080') ? '?' : c);
}
return charCount;
}
/// <summary>Decodes a sequence of bytes starting at the specified byte pointer into a set of characters that are stored starting at the specified character pointer.</summary>
/// <returns>The actual number of characters written at the location indicated by <paramref name="chars" />.</returns>
/// <param name="bytes">A pointer to the first byte to decode.</param>
/// <param name="byteCount">The number of bytes to decode.</param>
/// <param name="chars">A pointer to the location at which to start writing the resulting set of characters.</param>
/// <param name="charCount">The maximum number of characters to write.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="bytes" /> is null.-or- <paramref name="chars" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="byteCount" /> or <paramref name="charCount" /> is less than zero. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="charCount" /> is less than the resulting number of characters. </exception>
/// <exception cref="T:System.Text.DecoderFallbackException">A fallback occurred (see Understanding Encodings for complete explanation)-and-<see cref="P:System.Text.Encoding.DecoderFallback" /> is set to <see cref="T:System.Text.DecoderExceptionFallback" />.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036C5 RID: 14021 RVA: 0x000BC19C File Offset: 0x000BA39C
[CLSCompliant(false)]
[ComVisible(false)]
public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount)
{
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (chars == null)
{
throw new ArgumentNullException("chars");
}
if (charCount < 0)
{
throw new ArgumentOutOfRangeException("charCount");
}
if (byteCount < 0)
{
throw new ArgumentOutOfRangeException("byteCount");
}
if (charCount < byteCount)
{
throw new ArgumentException("charcount is less than the number of bytes required", "charCount");
}
for (int i = 0; i < byteCount; i++)
{
byte b = bytes[i];
chars[i] = ((b <= 127) ? ((char)b) : '?');
}
return byteCount;
}
/// <summary>Calculates the number of characters produced by decoding a sequence of bytes starting at the specified byte pointer.</summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">A pointer to the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="bytes" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="count" /> is less than zero.-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer. </exception>
/// <exception cref="T:System.Text.DecoderFallbackException">A fallback occurred (see Understanding Encodings for complete explanation)-and-<see cref="P:System.Text.Encoding.DecoderFallback" /> is set to <see cref="T:System.Text.DecoderExceptionFallback" />.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036C6 RID: 14022 RVA: 0x000BC238 File Offset: 0x000BA438
[ComVisible(false)]
[CLSCompliant(false)]
public unsafe override int GetCharCount(byte* bytes, int count)
{
return count;
}
/// <summary>Calculates the number of bytes produced by encoding a set of characters starting at the specified character pointer.</summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="chars">A pointer to the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="chars" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="count" /> is less than zero.-or- The resulting number of bytes is greater than the maximum number that can be returned as an integer. </exception>
/// <exception cref="T:System.Text.EncoderFallbackException">A fallback occurred (see Understanding Encodings for complete explanation)-and-<see cref="P:System.Text.Encoding.EncoderFallback" /> is set to <see cref="T:System.Text.EncoderExceptionFallback" />.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060036C7 RID: 14023 RVA: 0x000BC23C File Offset: 0x000BA43C
[ComVisible(false)]
[CLSCompliant(false)]
public unsafe override int GetByteCount(char* chars, int count)
{
return count;
}
/// <summary>Obtains a decoder that converts an ASCII encoded sequence of bytes into a sequence of Unicode characters.</summary>
/// <returns>A <see cref="T:System.Text.Decoder" /> that converts an ASCII encoded sequence of bytes into a sequence of Unicode characters.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x060036C8 RID: 14024 RVA: 0x000BC240 File Offset: 0x000BA440
[ComVisible(false)]
[MonoTODO("we have simple override to match method signature.")]
public override Decoder GetDecoder()
{
return base.GetDecoder();
}
/// <summary>Obtains an encoder that converts a sequence of Unicode characters into an ASCII encoded sequence of bytes.</summary>
/// <returns>An <see cref="T:System.Text.Encoder" /> that converts a sequence of Unicode characters into an ASCII encoded sequence of bytes.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x060036C9 RID: 14025 RVA: 0x000BC248 File Offset: 0x000BA448
[ComVisible(false)]
[MonoTODO("we have simple override to match method signature.")]
public override Encoder GetEncoder()
{
return base.GetEncoder();
}
// Token: 0x04001662 RID: 5730
internal const int ASCII_CODE_PAGE = 20127;
}
}