Big-endian binary reader : Encoding « Internationalization I18N « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » Internationalization I18N » EncodingScreenshots 
Big-endian binary reader
       
/// Copyright (c) 2008 Jeffrey Powers for Fluxcapacity Open Source.
/// Under the MIT License, details: License.txt.

using System;
using System.IO;

namespace FluxJpeg.Core.IO
{
    /// <summary>
    /// Big-endian binary reader
    /// </summary>
    internal class BinaryReader
    {
        Stream _stream;
        byte[] _buffer;

        public Stream BaseStream get return _stream; } }

        public BinaryReader(byte[] datathis(new MemoryStream(data)) { }

        public BinaryReader(Stream stream)
        {
            _stream = stream;
            _buffer = new byte[2];
        }

        public byte ReadByte()
        {
            int b = _stream.ReadByte();
            if (b == -1throw new EndOfStreamException();
            return (byte)b;
        }

        public ushort ReadShort()
        {
            _stream.Read(_buffer, 02);
            return (ushort)((_buffer[0<< 8(_buffer[10xff));
        }

        public int Read(byte[] buffer, int offset, int count)
        {
            return _stream.Read(buffer, offset, count);
        }

    }
}

   
    
    
    
    
    
    
  
Related examples in the same category
1.Encoding Class represents a character encoding.
2.Encoding.ASCII encoding for the ASCII (7-bit) character set.
3.Gets an encoding for the UTF-16 format that uses the big endian byte order.
4.Read a text file saved with Big Endian Unicode encoding
5.Get byte count and max byte count
6.Display only the encodings that have one or more different names
7.Returns an array that contains all encodings.
8.Returns a sequence of bytes that specifies the encoding used.
9.Gets an encoding for the UTF-32 format using the little endian byte order.
10.Gets an encoding for the UTF-8 format.
11.Gets the Windows operating system code page that most closely corresponds to the current encoding.
12.Petscii Decoder
13.Petscii Encoder
14.extends System.Text.Encoding to create Petscii Encoding
15.SignedLoWord from IntPtr
16.SignedHiWord from IntPtr
17.Pad data to a WORD.
18.Returns the high WORD from a DWORD value.
19.Signed Lo Word
20.Signed Hi Word
21.Flip Endian
22.A Big-endian binary writer.
23.EBCDIC To ASCII
24.Is Chinese Character
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.