Read Unicode using BinaryReader - CSharp System.IO

CSharp examples for System.IO:BinaryReader

Description

Read Unicode using BinaryReader

Demo Code


using System.Text;
using System.IO;//w w w.  j  a va2s  .  c om
using System;

public class Main{
        public static string ReadUnicode(this BinaryReader reader, int len)
        {
            byte[] unicode = reader.ReadBytes(len * 2);
            string text = Encoding.Unicode.GetString(unicode);
            text = text.Substring(0, text.IndexOf('\0'));
            return text;
        }
}

Related Tutorials