System.Text.ISO2022Encoding.GetBytes C# (CSharp) Method

GetBytes() private method

private GetBytes ( char chars, int charCount, byte bytes, int byteCount, EncoderNLS baseEncoder ) : int
chars char
charCount int
bytes byte
byteCount int
baseEncoder EncoderNLS
return int
        public unsafe override int GetBytes(char* chars, int charCount,
                                                byte* bytes, int byteCount, EncoderNLS baseEncoder)
        {
            // Just need to ASSERT, this is called by something else internal that checked parameters already
            Debug.Assert(chars != null, "[ISO2022Encoding.GetBytes]chars is null");
            Debug.Assert(byteCount >= 0, "[ISO2022Encoding.GetBytes]byteCount is negative");
            Debug.Assert(charCount >= 0, "[ISO2022Encoding.GetBytes]charCount is negative");

            // Assert because we shouldn't be able to have a null encoder.
            Debug.Assert(EncoderFallback != null, "[ISO2022Encoding.GetBytes]Attempting to use null encoder fallback");

            // Fix our encoder
            ISO2022Encoder encoder = (ISO2022Encoder)baseEncoder;

            // Our return value
            int iCount = 0;

            switch (CodePage)
            {
                case 50220:
                case 50221:
                case 50222:
                    iCount = GetBytesCP5022xJP(chars, charCount, bytes, byteCount, encoder);
                    break;
                case 50225:
                    iCount = GetBytesCP50225KR(chars, charCount, bytes, byteCount, encoder);
                    break;
                // Everett had 50227 the same as 936
                /*              case 50227:
                                    iCount = GetBytesCP50227CN( chars, charCount, bytes, byteCount, encoder );
                                    break;
                */
                case 52936:
                    iCount = GetBytesCP52936(chars, charCount, bytes, byteCount, encoder);
                    break;
            }

            return iCount;
        }