using System; using System.Buffers; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace JsonRPC4.Router.Utilities { internal class StreamUtil { internal static MemoryStream GetStreamFromUtf8String(string utf8Text) { byte[] array = ArrayPool.Shared.Rent(Encoding.UTF8.GetByteCount(utf8Text)); int bytes = Encoding.UTF8.GetBytes(utf8Text, 0, utf8Text.Length, array, 0); return new MemoryStream(array, 0, bytes); } } }