{"id":17137162,"url":"https://github.com/squeek502/zigescape","last_synced_at":"2025-04-13T09:25:42.271Z","repository":{"id":77411307,"uuid":"413232656","full_name":"squeek502/zigescape","owner":"squeek502","description":"A tool for converting between binary data and Zig string literals","archived":false,"fork":false,"pushed_at":"2024-03-12T00:35:03.000Z","size":16,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T01:03:23.466Z","etag":null,"topics":["escaping","string-literals","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/squeek502.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":["squeek502"]}},"created_at":"2021-10-04T00:44:29.000Z","updated_at":"2024-11-23T23:02:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"d48b8bd4-af3a-4ee6-979e-e7dcaa90a889","html_url":"https://github.com/squeek502/zigescape","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squeek502%2Fzigescape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squeek502%2Fzigescape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squeek502%2Fzigescape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squeek502%2Fzigescape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/squeek502","download_url":"https://codeload.github.com/squeek502/zigescape/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248690073,"owners_count":21146057,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["escaping","string-literals","zig"],"created_at":"2024-10-14T20:06:23.375Z","updated_at":"2025-04-13T09:25:42.239Z","avatar_url":"https://github.com/squeek502.png","language":"Zig","funding_links":["https://github.com/sponsors/squeek502"],"categories":[],"sub_categories":[],"readme":"zigescape\n=========\n\nA tool for converting between binary data and [Zig](https://ziglang.org/) string literals.\n\nThe original motivation for this was to be able to easily turn inputs found via fuzz testing into strings that can be used in Zig test cases ([like in the tests added by this commit](https://github.com/ziglang/zig/pull/9880/commits/36f1f4f9fe39492367445b60153d7217533fb379)).\n\nBasic example (more can be found below):\n\n```sh\n$ echo '00 01 02 03 04' | xxd -r -p | zigescape\n\"\\x00\\x01\\x02\\x03\\x04\"\n```\n\nor with the `--hex` option, this can be done directly:\n\n```sh\n$ zigescape --hex \"00 01 02 03 04\"\n\"\\x00\\x01\\x02\\x03\\x04\"\n```\n\n## Building / Installation\n\n### Precompiled binaries\n\n1. Go to the [latest release](https://github.com/squeek502/zigescape/releases/latest)\n2. Download the relevant asset for your OS\n3. Rename to `zigescape` or `zigescape.exe` and give it executable permission (if necessary on your OS)\n4. Move the executable somewhere in your `PATH`\n\n### From Source\n\nRequires latest master of Zig.\n\n2. `zig build`\n3. The compiled binary will be in `zig-out/bin`\n4. `mv` or `ln` the binary somewhere in your `PATH`\n\n## Usage\n\n```\nUsage: zigescape [-hsx] [-o \u003cPATH\u003e] \u003cINPUT\u003e\n\n\u003cINPUT\u003e: Either a path to a file, or a Zig string literal (if using --string),\n         or a series of hex bytes in string format (if using --hex).\n         If \u003cINPUT\u003e is not specified, then stdin is used.\n\nAvailable options:\n\n-h, --help             Display this help and exit.\n\n-o, --output \u003cPATH\u003e    Output file path (stdout is used if not specified).\n\n-s, --string           Specifies that the input is a Zig string literal.\n                       Output will be the parsed string.\n\n-x, --hex              Specifies that the input is a series of hex bytes\n                       in string format (e.g. \"0A B4 10\").\n                       Output will be a Zig string literal.\n```\n\n## Examples\n\n### Converting *to* a string literal:\n\n```\nzigescape path/to/file\n```\n\nor\n\n```\nzigescape \u003c path/to/file\n```\n\nor, if you want to output to a file:\n\n```\nzigescape path/to/file -o path/to/outfile\n```\n\nor, if you want to convert from a series of hex bytes in string format:\n\n```\nzigescape --hex \"00 01 02 03 04\"\n```\n\n### Converting *from* string literal\n\n\u003e Note: shell escaping of arguments can mess with the string literal before it gets parsed, so it's best to use single quotes to bypass shell escaping. \n\n```\nzigescape --string '\"hello world\\n\"'\n```\n\nThe double quotes are optional, `zigescape` will add them if they are missing:\n\n```\nzigescape --string 'hello world\\n'\n```\n\nTo convert from a series of hex bytes to a string literal and then into a binary file:\n\n```\nzigescape --hex \"00 01 02 03 04\" | zigescape --string -o outfile.bin\n```\n\n### Some silly examples\n\n`cat`ing a file by converting it to a string literal and then parsing it to stdout:\n\n```\nzigescape path/to/file | zigescape --string\n```\n\nCopying a file by converting it to a string literal and then parsing it:\n\n```\nzigescape path/to/file.orig | zigescape --string -o path/to/file.copy\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqueek502%2Fzigescape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqueek502%2Fzigescape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqueek502%2Fzigescape/lists"}