public static Rune FromUtf32(byte[] array, ref int index, ByteOrder endianness = ByteOrder.LittleEndian) { if (index + 4 > array.Length) { throw new ArgumentOutOfRangeException("index", "Need 4 bytes to process Utf32"); } var decoder = new Utf32.ByteDecoder(endianness); decoder.Process(array[index++]); decoder.Process(array[index++]); decoder.Process(array[index++]); var result = decoder.Process(array[index++]); return(new Rune(result.GetValueOrDefault())); }
// byte.Utf32... -> Rune public static IEnumerable <Rune> AsUtf32Runes(this IEnumerable <byte> bytes, ByteOrder endianness = ByteOrder.LittleEndian) { var decoder = new Utf32.ByteDecoder(endianness); return(DecodeValues(bytes, decoder, "Ill-formed Utf32.")); }