System.Xml.XmlUtf8RawTextWriter.EncodeSurrogate C# (CSharp) Méthode

EncodeSurrogate() private static méthode

private static EncodeSurrogate ( char pSrc, char pSrcEnd, byte pDst ) : byte*
pSrc char
pSrcEnd char
pDst byte
Résultat byte*
        private static unsafe byte* EncodeSurrogate( char* pSrc, char* pSrcEnd, byte* pDst ) {
            Debug.Assert( InRange( *pSrc, SurHighStart, SurLowEnd ) );

            int ch = *pSrc;
            if ( ch <= SurHighEnd ) {
                if ( pSrc + 1 < pSrcEnd ) {
                    int lowChar = pSrc[1];
                    if ( lowChar >= SurLowStart ) {

                        // Calculate Unicode scalar value for easier manipulations (see section 3.7 in Unicode spec)
                        // The scalar value repositions surrogate values to start at 0x10000.
                        
                        ch = lowChar + (ch << 10) + (0x10000 - SurLowStart - (SurHighStart << 10) );

                        pDst[0] = (byte)( 0xF0 | ( ch >> 18 ) );
                        pDst[1] = (byte)( 0x80 | ( ch >> 12 ) & 0x3F );
                        pDst[2] = (byte)( 0x80 | ( ch >> 6  ) & 0x3F );
                        pDst[3] = (byte)( 0x80 | ch & 0x3F);
                        pDst += 4;





                        return pDst;
                    }
                    throw XmlConvert.CreateInvalidSurrogatePairException( (char)lowChar, (char)ch );
                }
                throw new ArgumentException( Res.GetString( Res.Xml_InvalidSurrogateMissingLowChar ) );
            }
            throw XmlConvert.CreateInvalidHighSurrogateCharException( (char)ch );
        }