SwiftyBytes

0.4.5

A binary read/write library written in Swift.
Xenoxiluna/SwiftyBytes

What's New

v0.4.5

2020-10-03T22:58:00Z

Corrected Protection for BinaryWriter WriteIndex Property

SwiftyBytes

Swift 5.X GitHub license Docs Build Status

A binary file read/write library written in swift. It was created with the purpose of being able to somewhat easily read game data files.

NOTE: writeString prefixes the length of the given string as a generic Int. This could cause compatibility issues on 32/64-bit systems

Usage

Write: LittleEndian

var writeTest: BinaryWriter = BinaryWriter()
try writeTest.writeVariableLengthString("This is a test!", .ascii)
try writeTest.writeNullTerminatedString("This is my second test!", .ascii)
try writeTest.writeUInt64(866464616516564)

Write: BigEndian

var writeTest: BinaryWriter = BinaryWriter()
try writeTest.writeUInt64(866464616516564, bigEndian: true)

Read: LittleEndian

var reader: BinaryReader = BinaryReader(writeTest.data)
print("\(try reader.readVariableLengthString(.ascii))")
print("\(try reader.readNullTerminatedString(.ascii))")
print("\(try reader.readUInt64())")

Read: BigEndian

var reader: BinaryReader = BinaryReader(writeTest.data)
print("\(try reader.readUInt64(true))")

License

SwiftyBytes is licensed under the MIT License

Description

  • Swift Tools 5.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Mar 17 2024 00:18:59 GMT-0900 (Hawaii-Aleutian Daylight Time)