+ if (byteCount == 0)
+ return 0;
+
+ int charCount = chars.Length - charIndex;
+ if (chars.Length == 0)
+ chars = new char [1];
+
+ fixed (byte* bytePtr = bytes)
+ fixed (char* charPtr = chars)
+ return GetCharsInternal (bytePtr + byteIndex, byteCount, charPtr + charIndex, charCount);
+}
+
+#if NET_2_0
+ [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");
+
+ return GetCharsInternal (bytes, byteCount, chars, charCount);
+ }
+#endif
+
+ // Decode a buffer of bytes into a string.
+ [ComVisible (false)]
+ public unsafe override String GetString (byte [] bytes, int index, int count)
+ {
+ if (bytes == null)
+ throw new ArgumentNullException ("bytes");
+ if (index < 0 || index > bytes.Length)
+ throw new ArgumentOutOfRangeException ("index", _("ArgRange_Array"));
+ if (count < 0 || count > (bytes.Length - index))
+ throw new ArgumentOutOfRangeException ("count", _("ArgRange_Array"));
+
+ if (count == 0)
+ return string.Empty;
+
+ // GetCharCountInternal
+ int charCount = count / 2;
+ string s = string.InternalAllocateStr (charCount);
+
+ fixed (byte* bytePtr = bytes)
+ fixed (char* charPtr = s)
+ GetCharsInternal (bytePtr + index, count, charPtr, charCount);
+
+ return s;
+ }
+
+ private unsafe int GetCharsInternal (byte* bytes, int byteCount,
+ char* chars, int charCount)
+ {
+ int count = byteCount / 2;