System.Extensions.GetBytes C# (CSharp) Method

GetBytes() public static method

public static GetBytes ( this nativeUtf8 ) : byte[]
nativeUtf8 this
return byte[]
        public static byte[] GetBytes(this IntPtr nativeUtf8)
        {
            int len = 0;
            
            while (Marshal.ReadByte(nativeUtf8, len) != 0) 
                ++len;
            
            if (len == 0) 
                return new byte[1] {0};
            
            byte[] buffer = new byte[len];
            Marshal.Copy(nativeUtf8, buffer, 0, buffer.Length);
            //buffer[buffer.Length - 1] = 0;

            return buffer;
        }