System.Xml.Ucs4Decoder.GetChars C# (CSharp) Méthode

GetChars() public méthode

public GetChars ( byte bytes, int byteIndex, int byteCount, char chars, int charIndex ) : int
bytes byte
byteIndex int
byteCount int
chars char
charIndex int
Résultat int
        public override int GetChars( byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex ) {
            // finish a character from the bytes that were cached last time
            int i = lastBytesCount;
            if ( lastBytesCount > 0 ) {
                // copy remaining bytes into the cache
                for ( ; lastBytesCount < 4 && byteCount > 0; lastBytesCount++ ) {
                    lastBytes[lastBytesCount] = bytes[byteIndex];
                    byteIndex++;
                    byteCount--;
                }
                // still not enough bytes -> return
                if ( lastBytesCount < 4 ) {
                    return 0;
                }
                // decode 1 character from the byte cache
                i = GetFullChars( lastBytes, 0 , 4, chars, charIndex );
                Debug.Assert( i == 1 );
                charIndex += i;
                lastBytesCount = 0;
            }
            else {
                i = 0;
            }

            // decode block of byte quadruplets
            i = GetFullChars( bytes, byteIndex, byteCount, chars, charIndex ) + i;

            // cache remaining bytes that does not make up a character
            int bytesLeft = ( byteCount & 0x3 );
            if ( bytesLeft >= 0 ) {
                for( int j = 0; j < bytesLeft; j++ ) {
                    lastBytes[j] = bytes[byteIndex + byteCount - bytesLeft + j];
                }
                lastBytesCount = bytesLeft;
            }
            return i;
        }

Usage Example

 public override Int32 GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex)
 {
     return(ucs4Decoder.GetChars(bytes, byteIndex, byteCount, chars, charIndex));
 }
All Usage Examples Of System.Xml.Ucs4Decoder::GetChars