GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - eouna/pack-binary: use to read or write binary files / binary data stream

BranchesTags
Open more actions menu

Latest commit

 

History

28 Commits
28 Commits

Folders and files

NameName
Last commit message
Last commit date
example
example
 
 
src/BinaryStream
src/BinaryStream
 
 
test
test
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
README_CN.md
README_CN.md
 
 
_config.yml
_config.yml
 
 
autoload.php
autoload.php
 
 
composer.json
composer.json
 
 

Repository files navigation

PHP Read And Write Binary Stream Package

Binary Stream Packager - a tools to handle binary data or stream

  • 中文版

  • Manual

    • Write Stream Method
      use BinaryStream\BinaryWriter;
      $writer = new BinaryWriter();
      $writer->writeUTFString( str_repeat("It`s long string,", 200) );
      $writer->writeUTFString("");
      $writer->writeInt32(-90);
      $writer->writeDouble(800);
      $writer->writeFloat(3.88511321334343434324443324321);
      $writer->writeDouble(148.3243413243132134343213244313132);
      $writer->writeChar("s");
      $byteWriter = new ByteWriter();
      $byteWriter->writeByte(120);
      $byteWriter->writeInt16ToByte(65530);
      $byteWriter->writeInt32ToByte(1526456146);
      $writer->writeByteObject($byteWriter);
    • note

      1. the default encode method is BIG ENDIAN you can use method setBinaryModel to change it
       $write->setBinaryModel(BinaryCode::LITTLE_ENDIAN | BinaryCode::BIG_ENDIAN);
      1. the default write flag to store file is FILE_BINARY you can use method store to change it
         $writer->store(FILE_APPEND);
        //or 
        $writer->store(FILE_TEXT);
        //or
        $writer->store(FILE_APPEND | LOCK_EX);
    • Read Stream Method
      the read sequence must match with the write sequence
      $reader = new BinaryReader($writer->getWriteStream());
      $res[] = $reader->readUTFString();
      $res[] = $reader->readUTFString();
      $res[] = $reader->readInt32();
      $res[] = $reader- >readDouble();
      $res[] = $reader->readDouble();
      $res[] = $reader->readFloat();
      $res[] = $reader->readDouble();
      $res[] =  $reader->readChar();
      $byteReader = $reader->readByByteReader();
      $res[] = $byteReader->readByte();
      $res[] = $byteReader->readBytesToShort();
      $res[] = $byteReader->readByteToInt32();
      
  • How To Use It

use

composer require eouna/pack-binary

to install this package

About

use to read or write binary files / binary data stream

Topics

binarybinary-bufferbinary-streamdatastreamstream

Resources

Readme
MIT license
Activity

Stars

5 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.