Skip to content

Instantly share code, notes, and snippets.

@ForeverZer0
Created February 17, 2020 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ForeverZer0/429e876f83fd3061c9784cde92857056 to your computer and use it in GitHub Desktop.
Save ForeverZer0/429e876f83fd3061c9784cde92857056 to your computer and use it in GitHub Desktop.
Converts any file to C char array to embed as resource.

Convert any file to formatted string of hex characters

#!/usr/bin/bash
hexdump -v -e '16/1 "_x%02X" "\n"' $1 | sed 's/_/\\/g; s/\\x  //g; s/.*/    "&"/'

The output can then be copied and assigned to a const char * in a header/source file and referenced as a normal string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment