public unsafe void Utf8EncodeDecode([Range(0, 0xD7FF, 997)] int input_ucs) { var converted = new byte[4]; fixed(byte *c = converted) { ConversionError error; int write_length = 0; error = NativeString.UcsToUtf8(c, ref write_length, converted.Length, input_ucs); Assert.AreEqual(ConversionError.None, error); int read_length = 0; error = NativeString.Utf8ToUcs(out int output_ucs, c, ref read_length, write_length); Assert.AreEqual(ConversionError.None, error); Assert.AreEqual(write_length, read_length); Assert.AreEqual(output_ucs, input_ucs); } }