How do I turn binary file data into hex representation

2022-10-17 Thread treeform
In flatty i have hex print which I use for debugging binary files: Sentence: : 48 69 20 68 6F 77 20 61-72 65 20 79 6F 75 20 64 Hi how are you d 0010: 6F 69 6E 67 20 74 6F 64-61 79 3F .. .. .. .. .. oing today? ASCII: :

How do I turn binary file data into hex representation

2022-10-17 Thread Zoom
> It is completely broken. Please help. It's not, maybe check how you compare the bytes. import std/[sequtils, strutils] proc toHexSeq(str: string): seq[string] = let hex = str.toHex() for i, x in hex: if (i mod 2) > 0: result.add(hex[i-1] & x)

How do I turn binary file data into hex representation

2022-10-16 Thread Nlits
Example of the first part of my problem: Expected bytes > BIMG010a���###$$$%%%"""!!!�� What I got from toHex(And back again) > BIMG010aººº###$$$%%%"""!!!ºï It is completely broken. Please help. Conversion script: proc toHexSeq(str:string): seq[string] =

How do I turn binary file data into hex representation

2022-10-15 Thread Zoom
Getting a byte from the file is just reading it. There's a bunch of ways to do it, most of them involve some type of `read` proc. func genByteToCharLUT(): array[byte, array[2, char]] = const HexChars = "0123456789ABCDEF" for i in 0.byte .. 255: result[i] = [HexCha

How do I turn binary file data into hex representation

2022-10-15 Thread exelotl
You'll have to show us an example (code, input, output, screenshots) as it's not entirely clear what you're asking.

How do I turn binary file data into hex representation

2022-10-15 Thread Nlits
How do i get the byte from the file? That was my main problem. The original binary string was messed up.

How do I turn binary file data into hex representation

2022-10-15 Thread auxym
There is toHex in strutils: You'll have to chunk the resulting string into 2-character strings yourself though, which you can do with eg countUp.

How do I turn binary file data into hex representation

2022-10-15 Thread Zoom
It's all there in [strformat](https://nim-lang.org/docs/strformat.html), if you can get through the docs. import std/strformat let foo = 3735928559 echo fmt("{foo:X}") stdout.write('[') for i, n in [42,52,91]: if i > 0: stdout.write(',') stdout.write(

How do I turn binary file data into hex representation

2022-10-14 Thread Nlits
> Converting binary 2 string is corrupting my bytes! how do I just get a hex > rep of a binary file! I want hex as in `[2A,34,5B]` or `[0x2A,0x34,0x5B]` Anyone know how I would do this?