+
+#if NET_2_0
+ [CLSCompliantAttribute (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 < (char) 0x80) ? c : '?');
+ }
+ return charCount;
+ }
+
+ [CLSCompliantAttribute(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;
+
+ }
+
+ [CLSCompliantAttribute(false)]
+ [ComVisible (false)]
+ public unsafe override int GetCharCount (byte *bytes, int count)
+ {
+ return count;
+ }
+
+ [CLSCompliantAttribute(false)]
+ [ComVisible (false)]
+ public unsafe override int GetByteCount (char *chars, int count)
+ {
+ return count;
+ }
+#else
+ // This routine is gone in 2.x