System.Text.Encoding.GetChars C# (CSharp) Method

GetChars() public method

public GetChars ( byte bytes ) : char[]
bytes byte
return char[]
        public virtual char[] GetChars(byte[] bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException("bytes",
                    Environment.GetResourceString("ArgumentNull_Array"));
            }
            return GetChars(bytes, 0, bytes.Length);
        }

Same methods

Encoding::GetChars ( byte bytes, int index, int count ) : char[]
Encoding::GetChars ( byte bytes, int byteCount, char chars, int charCount ) : int
Encoding::GetChars ( byte bytes, int byteCount, char chars, int charCount, DecoderNLS decoder ) : int
Encoding::GetChars ( byte bytes, int byteIndex, int byteCount, char chars, int charIndex ) : int

Usage Example

示例#1
0
        public bool TryReadTextString(Span <char> destination, out int charsWritten)
        {
            CborInitialByte header = PeekInitialByte(expectedType: CborMajorType.TextString);

            if (header.AdditionalInfo == CborAdditionalInfo.IndefiniteLength)
            {
                return(TryReadChunkedTextStringConcatenated(destination, out charsWritten));
            }

            int byteLength = checked ((int)ReadUnsignedInteger(_buffer.Span, header, out int additionalBytes));

            EnsureBuffer(1 + additionalBytes + byteLength);

            ReadOnlySpan <byte> encodedSlice = _buffer.Span.Slice(1 + additionalBytes, byteLength);

            int charLength = ValidateUtf8AndGetCharCount(encodedSlice);

            if (charLength > destination.Length)
            {
                charsWritten = 0;
                return(false);
            }

            s_utf8Encoding.GetChars(encodedSlice, destination);
            AdvanceBuffer(1 + additionalBytes + byteLength);
            AdvanceDataItemCounters();
            charsWritten = charLength;
            return(true);
        }
All Usage Examples Of System.Text.Encoding::GetChars