/// <summary> /// Construct a BufferedReader to read the UTF8 bytes of a string. /// </summary> /// <param name="text">String to convert</param> /// <param name="convertBuffer">Reusable buffer to convert into</param> /// <returns>BufferedReader reading string value only</returns> public static BufferedReader FromString(string text, ref byte[] convertBuffer) { int length = Encoding.UTF8.GetByteCount(text); if (convertBuffer == null || convertBuffer.Length < length) { convertBuffer = new byte[length]; } Encoding.UTF8.GetBytes(text, convertBuffer); return(BufferedReader.FromArray(convertBuffer, 0, length)); }
/// <summary> /// Construct a BufferedReader to read a String8 value. /// </summary> /// <param name="text">String8 to read</param> /// <returns>BufferedReader reading String8 value only</returns> public static BufferedReader FromString(String8 text) { return(BufferedReader.FromArray(text.Array, text.Index, text.Length)); }