示例#1
0
文件: BlobReader.cs 项目: jnm2/corefx
        /// <summary>
        /// Reads UTF8 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 ReadUTF8(int byteCount)
        {
            string s = _block.PeekUtf8(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.PeekUtf8(offset, size - 1));
        }