All Projects → njh → hext

njh / hext

Licence: MIT license
Markup language and tool for generating binary files

Programming Languages

c
50402 projects - #5 most used programming language
shell
77523 projects
Makefile
30231 projects
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to hext

SwiftRadix
Easily convert integers to binary/hex/octal strings and back again with clean functional syntax.
Stars: ✭ 34 (+47.83%)
Mutual labels:  hex, binary
literate-binary
Integrate handcrafted binary and documentation
Stars: ✭ 37 (+60.87%)
Mutual labels:  hex, binary
Heksa
CLI hex dumper with colors
Stars: ✭ 133 (+478.26%)
Mutual labels:  hex, binary
buffertools-php
Toolbox for working with binary and hex data. Similar to NodeJS Buffer.
Stars: ✭ 60 (+160.87%)
Mutual labels:  hex, binary
Tints And Shades
🌈 Display tints and shades of a given hex color in 10% increments.
Stars: ✭ 228 (+891.3%)
Mutual labels:  hex
Hexed
Windows console-based hex editor
Stars: ✭ 145 (+530.43%)
Mutual labels:  hex
Midas
A web framework for Gleam, Midas makes shiny things.
Stars: ✭ 137 (+495.65%)
Mutual labels:  hex
Intelhex
Python IntelHex library
Stars: ✭ 116 (+404.35%)
Mutual labels:  hex
jomini
Low level, performance oriented parser for save and game files from EU4, CK3, HOI4, Vic3, Imperator, and other PDS titles.
Stars: ✭ 40 (+73.91%)
Mutual labels:  binary
Xprof
A visual tracer and profiler for Erlang and Elixir.
Stars: ✭ 246 (+969.57%)
Mutual labels:  hex
Elixir Json
Native JSON library for Elixir
Stars: ✭ 216 (+839.13%)
Mutual labels:  hex
Table rex
An Elixir app which generates text-based tables for display
Stars: ✭ 161 (+600%)
Mutual labels:  hex
Dynamiccolor
Yet another extension to manipulate colors easily in Swift and SwiftUI
Stars: ✭ 2,677 (+11539.13%)
Mutual labels:  hex
Gradstop
JavaScript micro library to generate gradient color stops 🏳️‍🌈
Stars: ✭ 144 (+526.09%)
Mutual labels:  hex
fpbinary
Fixed point package for Python.
Stars: ✭ 30 (+30.43%)
Mutual labels:  binary
Civitas
Civitas is an empire-building game written in Javascript with the help of the jQuery library.
Stars: ✭ 207 (+800%)
Mutual labels:  hex
Neuron
A GraphQL client for Elixir
Stars: ✭ 244 (+960.87%)
Mutual labels:  hex
Number
ActionView::Helpers::NumberHelper for Elixir
Stars: ✭ 186 (+708.7%)
Mutual labels:  hex
Jscolor
JavaScript color picker with opacity (alpha channel) and customizable palette. Single file of plain JS with no dependencies.
Stars: ✭ 182 (+691.3%)
Mutual labels:  hex
Ecto mnesia
Ecto adapter for Mnesia Erlang term database.
Stars: ✭ 223 (+869.57%)
Mutual labels:  hex

binmark

Build Status

binmark is a markup language and tool for describing binary files, that is easier to read and write than a continuous stream of hexadecimal characters.

This implementation is a C/C++ library and command line tool.

The following characters are supported:

Character Description
0-9 and a-f A byte as hexadecimal. Must be two characters long.
Whitespace Ignored
Colon or Dash Ignored - useful for improving readability
.nnn A 8-bit decimal integer
"" A string of ASCII characters
# The start of a comment - the rest of the line is ignored
\ Escape sequences (\0 \a \b \f \n \r \t \v)

Example

Given the following sample input file, which is reasonably easy read:

30             # Packet Type 3: Publish
.17            # Remaining length (17 bytes)
0004           # Topic name length
"test"         # Topic name
"hello world"  # Payload

The default is to output as a binary stream - visualised here using the hexdump command:

./binmark -b tests/mqtt_publish.bm | hexdump -C
00000000  30 11 00 04 74 65 73 74  68 65 6c 6c 6f 20 77 6f  |0...testhello wo|
00000010  72 6c 64                                          |rld|
00000013

It is also possible to output as C data structure:

./binmark -c tests/mqtt_publish.bm
uint8_t buffer[] = {
    0x30, 0x11, 0x00, 0x04, 0x74, 0x65, 0x73, 0x74, 
    0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 
    0x72, 0x6c, 0x64
};

Or as a stream of hexadecimal text:

./binmark -x tests/mqtt_publish.bm
301100047465737468656c6c6f20776f726c64

But why?

I created binmark after my test cases, when writing test cases for my Arduino IPv6 Library, EtherSia, started resulting in long strings of hexadecimal characters in my code. I decided that these would be better in seperate external files and realised that I had the freedom to decide on the file format, to make them easier to read and write.

A long stream of hexadecimal is difficult to both read and write - particularly picking out the different fields and sections. By adding some whitespace, punctuation and comments, it is much easier.

Possible uses:

  • Describing expected data for automated tests
  • Creating new file formats before tools to generate them exist
  • Documenting a data structure in a human readable way
  • Alternative to a using a hex editor

Design Decisions

This was my thought process while designing binmark:

  • Readable and concise to write for humans
  • Simple for a machine to parse and convert
  • Streamable - don't require input to be loaded into a buffer more parsing
  • ASCII input - try and avoid potential weird character-set problems
  • Not so complex that there wouldn't be other implementations in other languages

Other Languages

License

binmark is licensed under the terms of the MIT license. See the file LICENSE for details.

Naming

binmark was originally written in 2016 with the name hext. It was renamed in 2023 to have a more unique name that wasn't being used by other projects.

Contact

  • Author: Nicholas J Humfrey
  • Twitter: @njh
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].