// called by the fallback mechanism private protected sealed override unsafe int GetCharsFast(byte *pBytes, int bytesLength, char *pChars, int charsLength, out int bytesConsumed) { int charsWritten = Math.Min(bytesLength, charsLength); Latin1Utility.WidenLatin1ToUtf16(pBytes, pChars, (uint)charsWritten); bytesConsumed = charsWritten; return(charsWritten); }
private unsafe int GetCharsCommon(byte *pBytes, int byteCount, char *pChars, int charCount) { // Common helper method for all non-DecoderNLS entry points to GetChars. // A modification of this method should be copied in to each of the supported encodings: ASCII, UTF8, UTF16, UTF32. Debug.Assert(byteCount >= 0, "Caller shouldn't specify negative length buffer."); Debug.Assert(pBytes != null || byteCount == 0, "Input pointer shouldn't be null if non-zero length specified."); Debug.Assert(charCount >= 0, "Caller shouldn't specify negative length buffer."); Debug.Assert(pChars != null || charCount == 0, "Input pointer shouldn't be null if non-zero length specified."); // If we already know ahead of time that the destination buffer isn't large enough to hold // the widened data, fail immediately. if (byteCount > charCount) { ThrowCharsOverflow(); } Latin1Utility.WidenLatin1ToUtf16(pBytes, pChars, (uint)byteCount); return(byteCount); }