System.Text.Encoder.GetByteCount C# (CSharp) Метод

GetByteCount() приватный Метод

private GetByteCount ( char chars, int count, bool flush ) : int
chars char
count int
flush bool
Результат int
        public virtual unsafe int GetByteCount(char* chars, int count, bool flush)
        {
            // Validate input parameters
            if (chars == null)
                throw new ArgumentNullException("chars",
                      Environment.GetResourceString("ArgumentNull_Array"));

            if (count < 0)
                throw new ArgumentOutOfRangeException("count",
                      Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));

            char[] arrChar = new char[count];
            int index;

            for (index = 0; index < count; index++)
                arrChar[index] = chars[index];

            return GetByteCount(arrChar, 0, count, flush);
        }

Same methods

Encoder::GetByteCount ( char chars, int index, int count, bool flush ) : int

Usage Example

Пример #1
0
        private unsafe void CreateFirstSubstData(string s, IIS7WorkerRequest iis7WorkerRequest, System.Text.Encoder encoder)
        {
            IntPtr ptr;
            int    num    = 0;
            int    length = s.Length;

            if (length > 0)
            {
                fixed(char *str = ((char *)s))
                {
                    char *chars = str;
                    int   size  = encoder.GetByteCount(chars, length, true);

                    ptr = iis7WorkerRequest.AllocateRequestMemory(size);
                    if (ptr != IntPtr.Zero)
                    {
                        num = encoder.GetBytes(chars, length, (byte *)ptr, size, true);
                    }
                }
            }
            else
            {
                ptr = iis7WorkerRequest.AllocateRequestMemory(1);
            }
            if (ptr == IntPtr.Zero)
            {
                throw new OutOfMemoryException();
            }
            this._firstSubstData     = ptr;
            this._firstSubstDataSize = num;
        }
All Usage Examples Of System.Text.Encoder::GetByteCount