Read String with Unicode Encoding - CSharp System.IO

CSharp examples for System.IO:BinaryReader

Description

Read String with Unicode Encoding

Demo Code


using System.Text;
using System.IO;//from  www  .  ja va 2s.c  o m
using System.Globalization;
using System;

public class Main{
        public static string ReadString(this BinaryReader br, int len, Encoding enc = null)
        {
            if (enc == null)
                enc = Encoding.Unicode;

            return enc.GetString(br.ReadBytes(len));
        }
}

Related Tutorials