예제 #1
0
파일: BlobReader.cs 프로젝트: jnm2/corefx
        /// <summary>
        /// Reads UTF16 (little-endian) encoded string starting at the current position.
        /// </summary>
        /// <param name="byteCount">The number of bytes to read.</param>
        /// <returns>The string.</returns>
        /// <exception cref="BadImageFormatException"><paramref name="byteCount"/> bytes not available.</exception>
        public string ReadUTF16(int byteCount)
        {
            string s = _block.PeekUtf16(this.Offset, byteCount);

            _currentPointer += byteCount;
            return(s);
        }
예제 #2
0
        internal string GetString(UserStringHandle handle)
        {
            int offset, size;
            if (!Block.PeekHeapValueOffsetAndSize(handle.GetHeapOffset(), out offset, out size))
            {
                return string.Empty;
            }

            // Spec: Furthermore, there is an additional terminal byte (so all byte counts are odd, not even). 
            // The size in the blob header is the length of the string in bytes + 1.
            return Block.PeekUtf16(offset, size & ~1);
        }