using System.Runtime.InteropServices;
[Serializable]
-#if NET_2_0
[ComVisible (true)]
-#endif
public abstract class Decoder
{
// Constructor.
protected Decoder () {}
-#if NET_2_0
DecoderFallback fallback = new DecoderReplacementFallback ();
DecoderFallbackBuffer fallback_buffer;
return fallback_buffer;
}
}
-#endif
// Get the number of characters needed to decode a buffer.
public abstract int GetCharCount (byte[] bytes, int index, int count);
public abstract int GetChars (byte[] bytes, int byteIndex, int byteCount,
char[] chars, int charIndex);
-#if NET_2_0
[ComVisible (false)]
public virtual int GetCharCount (byte [] bytes, int index, int count, bool flush)
{
CheckArguments (chars, charCount, bytes, byteCount);
char [] carr = new char [charCount];
- Marshal.Copy ((IntPtr) chars, carr, 0, charCount);
byte [] barr = new byte [byteCount];
Marshal.Copy ((IntPtr) bytes, barr, 0, byteCount);
- return GetChars (barr, 0, byteCount, carr, 0, flush);
+ int charsUsed = GetChars (barr, 0, byteCount, carr, 0, flush);
+ Marshal.Copy (carr, 0, (IntPtr) chars, charsUsed);
+ return charsUsed;
}
[ComVisible (false)]
out int bytesUsed, out int charsUsed, out bool completed)
{
CheckArguments (bytes, byteIndex, byteCount);
- CheckArguments (chars, charIndex);
+ if (chars == null)
+ throw new ArgumentNullException ("chars");
+ if (charIndex < 0)
+ throw new ArgumentOutOfRangeException ("charIndex");
if (charCount < 0 || chars.Length < charIndex + charCount)
throw new ArgumentOutOfRangeException ("charCount");
{
if (chars == null)
throw new ArgumentNullException ("chars");
- if (charIndex < 0 || chars.Length <= charIndex)
+ if (charIndex < 0 || chars.Length < charIndex)
throw new ArgumentOutOfRangeException ("charIndex");
}
{
if (bytes == null)
throw new ArgumentNullException ("bytes");
- if (byteIndex < 0 || bytes.Length <= byteIndex)
+ if (byteIndex < 0)
throw new ArgumentOutOfRangeException ("byteIndex");
if (byteCount < 0 || bytes.Length < byteIndex + byteCount)
throw new ArgumentOutOfRangeException ("byteCount");
if (byteCount < 0)
throw new ArgumentOutOfRangeException ("byteCount");
}
-#endif
-
}; // class Decoder
}; // namespace System.Text