using System;
using System.Runtime.InteropServices;
namespace System.Text
{
/// Converts a set of characters into a sequence of bytes.
/// 1
// Token: 0x020005E9 RID: 1513
[ComVisible(true)]
[Serializable]
public abstract class Encoder
{
/// Gets or sets a object for the current object.
/// A object.
/// The value in a set operation is null (Nothing).
/// A new value cannot be assigned in a set operation because the current object contains data that has not been encoded yet.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 1
// Token: 0x17000AC3 RID: 2755
// (get) Token: 0x0600370B RID: 14091 RVA: 0x000BCA54 File Offset: 0x000BAC54
// (set) Token: 0x0600370C RID: 14092 RVA: 0x000BCA5C File Offset: 0x000BAC5C
[ComVisible(false)]
public EncoderFallback Fallback
{
get
{
return this.fallback;
}
set
{
if (value == null)
{
throw new ArgumentNullException();
}
this.fallback = value;
this.fallback_buffer = null;
}
}
/// Gets the object associated with the current object.
/// A object.
/// 1
// Token: 0x17000AC4 RID: 2756
// (get) Token: 0x0600370D RID: 14093 RVA: 0x000BCA78 File Offset: 0x000BAC78
[ComVisible(false)]
public EncoderFallbackBuffer FallbackBuffer
{
get
{
if (this.fallback_buffer == null)
{
this.fallback_buffer = this.Fallback.CreateFallbackBuffer();
}
return this.fallback_buffer;
}
}
/// When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters from the specified character array. A parameter indicates whether to clear the internal state of the encoder after the calculation.
/// The number of bytes produced by encoding the specified characters and any characters in the internal buffer.
/// The character array containing the set of characters to encode.
/// The index of the first character to encode.
/// The number of characters to encode.
/// true to simulate clearing the internal state of the encoder after the calculation; otherwise, false.
///
/// is null.
///
/// or is less than zero.-or- and do not denote a valid range in .
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x0600370E RID: 14094
public abstract int GetByteCount(char[] chars, int index, int count, bool flush);
/// When overridden in a derived class, encodes a set of characters from the specified character array and any characters in the internal buffer into the specified byte array. A parameter indicates whether to clear the internal state of the encoder after the conversion.
/// The actual number of bytes written into .
/// The character array containing the set of characters to encode.
/// The index of the first character to encode.
/// The number of characters to encode.
/// The byte array to contain the resulting sequence of bytes.
/// The index at which to start writing the resulting sequence of bytes.
/// true to clear the internal state of the encoder after the conversion; otherwise, false.
///
/// is null (Nothing).-or- is null (Nothing).
///
/// or or is less than zero.-or- and do not denote a valid range in .-or- is not a valid index in .
///
/// does not have enough capacity from to the end of the array to accommodate the resulting bytes.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x0600370F RID: 14095
public abstract int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush);
/// When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters starting at the specified character pointer. A parameter indicates whether to clear the internal state of the encoder after the calculation.
/// The number of bytes produced by encoding the specified characters and any characters in the internal buffer.
/// A pointer to the first character to encode.
/// The number of characters to encode.
/// true to simulate clearing the internal state of the encoder after the calculation; otherwise, false.
///
/// is null (Nothing in Visual Basic .NET).
///
/// is less than zero.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x06003710 RID: 14096 RVA: 0x000BCAA8 File Offset: 0x000BACA8
[ComVisible(false)]
[CLSCompliant(false)]
public unsafe virtual int GetByteCount(char* chars, int count, bool flush)
{
if (chars == null)
{
throw new ArgumentNullException("chars");
}
if (count < 0)
{
throw new ArgumentOutOfRangeException("count");
}
char[] array = new char[count];
Marshal.Copy((IntPtr)((void*)chars), array, 0, count);
return this.GetByteCount(array, 0, count, flush);
}
/// When overridden in a derived class, encodes a set of characters starting at the specified character pointer and any characters in the internal buffer into a sequence of bytes that are stored starting at the specified byte pointer. A parameter indicates whether to clear the internal state of the encoder after the conversion.
/// The actual number of bytes written at the location indicated by the parameter.
/// A pointer to the first character to encode.
/// The number of characters to encode.
/// A pointer to the location at which to start writing the resulting sequence of bytes.
/// The maximum number of bytes to write.
/// true to clear the internal state of the encoder after the conversion; otherwise, false.
///
/// is null (Nothing).-or- is null (Nothing).
///
/// or is less than zero.
///
/// is less than the resulting number of bytes.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x06003711 RID: 14097 RVA: 0x000BCAF8 File Offset: 0x000BACF8
[ComVisible(false)]
[CLSCompliant(false)]
public unsafe virtual int GetBytes(char* chars, int charCount, byte* bytes, int byteCount, bool flush)
{
this.CheckArguments(chars, charCount, bytes, byteCount);
char[] array = new char[charCount];
Marshal.Copy((IntPtr)((void*)chars), array, 0, charCount);
byte[] array2 = new byte[byteCount];
Marshal.Copy((IntPtr)((void*)bytes), array2, 0, byteCount);
return this.GetBytes(array, 0, charCount, array2, 0, flush);
}
/// When overridden in a derived class, sets the encoder back to its initial state.
/// 2
// Token: 0x06003712 RID: 14098 RVA: 0x000BCB4C File Offset: 0x000BAD4C
[ComVisible(false)]
public virtual void Reset()
{
if (this.fallback_buffer != null)
{
this.fallback_buffer.Reset();
}
}
/// Converts a buffer of Unicode characters to an encoded byte sequence and stores the result in another buffer.
/// The address of a string of UTF-16 encoded characters to convert.
/// The number of characters in to convert.
/// The address of a buffer to store the converted bytes.
/// The maximum number of bytes in to use in the conversion.
/// true to indicate no further data is to be converted; otherwise, false.
/// When this method returns, contains the number of characters from that were used in the conversion. This parameter is passed uninitialized.
/// When this method returns, contains the number of bytes that were used in the conversion. This parameter is passed uninitialized.
/// When this method returns, contains true if all the characters specified by were converted; otherwise, false. This parameter is passed uninitialized.
///
/// or is null (Nothing).
///
/// or is less than zero.
/// The output buffer is too small to contain any of the converted input. The output buffer should be greater than or equal to the size indicated by the method.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x06003713 RID: 14099 RVA: 0x000BCB64 File Offset: 0x000BAD64
[ComVisible(false)]
[CLSCompliant(false)]
public unsafe virtual void Convert(char* chars, int charCount, byte* bytes, int byteCount, bool flush, out int charsUsed, out int bytesUsed, out bool completed)
{
this.CheckArguments(chars, charCount, bytes, byteCount);
charsUsed = charCount;
for (;;)
{
bytesUsed = this.GetByteCount(chars, charsUsed, flush);
if (bytesUsed <= byteCount)
{
break;
}
flush = false;
charsUsed >>= 1;
}
completed = charsUsed == charCount;
bytesUsed = this.GetBytes(chars, charsUsed, bytes, byteCount, flush);
}
/// Converts an array of Unicode characters to an encoded byte sequence and stores the result in an array of bytes.
/// An array of characters to convert.
/// The first element of to convert.
/// The number of elements of to convert.
/// An array where the converted bytes are stored.
/// The first element of in which data is stored.
/// The maximum number of elements of to use in the conversion.
/// true to indicate no further data is to be converted; otherwise, false.
/// When this method returns, contains the number of characters from that were used in the conversion. This parameter is passed uninitialized.
/// When this method returns, contains the number of bytes that were produced by the conversion. This parameter is passed uninitialized.
/// When this method returns, contains true if all the characters specified by were converted; otherwise, false. This parameter is passed uninitialized.
///
/// or is null (Nothing).
///
/// , , , or is less than zero.-or-The length of - is less than .-or-The length of - is less than .
/// The output buffer is too small to contain any of the converted input. The output buffer should be greater than or equal to the size indicated by the method.
/// A fallback occurred (see Understanding Encodings for fuller explanation)-and- is set to .
/// 2
// Token: 0x06003714 RID: 14100 RVA: 0x000BCBCC File Offset: 0x000BADCC
[ComVisible(false)]
public virtual void Convert(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, int byteCount, bool flush, out int charsUsed, out int bytesUsed, out bool completed)
{
if (chars == null)
{
throw new ArgumentNullException("chars");
}
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (charIndex < 0 || chars.Length <= charIndex)
{
throw new ArgumentOutOfRangeException("charIndex");
}
if (charCount < 0 || chars.Length < charIndex + charCount)
{
throw new ArgumentOutOfRangeException("charCount");
}
if (byteIndex < 0 || bytes.Length <= byteIndex)
{
throw new ArgumentOutOfRangeException("byteIndex");
}
if (byteCount < 0 || bytes.Length < byteIndex + byteCount)
{
throw new ArgumentOutOfRangeException("byteCount");
}
charsUsed = charCount;
for (;;)
{
bytesUsed = this.GetByteCount(chars, charIndex, charsUsed, flush);
if (bytesUsed <= byteCount)
{
break;
}
flush = false;
charsUsed >>= 1;
}
completed = charsUsed == charCount;
bytesUsed = this.GetBytes(chars, charIndex, charsUsed, bytes, byteIndex, flush);
}
// Token: 0x06003715 RID: 14101 RVA: 0x000BCCC4 File Offset: 0x000BAEC4
private unsafe void CheckArguments(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");
}
}
// Token: 0x04001676 RID: 5750
private EncoderFallback fallback = new EncoderReplacementFallback();
// Token: 0x04001677 RID: 5751
private EncoderFallbackBuffer fallback_buffer;
}
}