Page 1 of 1
BIN/TXT and TXT/BIN converters
Posted: Thu Sep 07, 2017 11:47 pm
by Mr. Kibernetik
According to discussion in
viewtopic.php?f=20&t=1938
these are BIN/TXT and TXT/BIN conversion programs for Windows.
Bin/Txt converter:
Code: Select all
in = "test.bin"
out = "test.txt"
d = #.readbytes(in)
s = #.size(d,1)
b = #.array(s*2)
> i, 1..s
x = #.array(#.str(d[i],"x2"))
b[i*2-1] = x[1]
b[i*2] = x[3]
<
#.writebytes(out,b)
#.output("Ok")
Txt/Bin converter:
Code: Select all
in = "test.txt"
out = "test.bin"
t = #.readtext(in,"ascii")
s = #.size(t)
b = #.array(s/2)
> i, 1..s/2
b[i] = #.val(#.mid(t,i*2-1,2)+"h")
<
#.writebytes(out,b)
? (i-1)*2=s, #.output("Ok")
Re: BIN/TXT and TXT/BIN converters
Posted: Sat Sep 09, 2017 11:29 pm
by rbytes
I started with a text file and converted it to bin with TXTtoBIN. It ran OK. When I looked at the resulting file test.bin" it appeared empty. I then tried converting it back to text with BINtoTXT and got completely different text than I started with.
I am now getting an error when running the TXTtoBIN program:
Re: BIN/TXT and TXT/BIN converters
Posted: Sat Sep 09, 2017 11:36 pm
by Mr. Kibernetik
What file are you converting which gives this error? Can you attach it to test?
Re: BIN/TXT and TXT/BIN converters
Posted: Sun Sep 10, 2017 1:57 am
by rbytes
I just used a paragraph of text copied off the web. Maybe I misunderstand your use of the .txt extender. Is the .txt file required to be only pure hex? I don't see this mentioned in the post.
Re: BIN/TXT and TXT/BIN converters
Posted: Sun Sep 10, 2017 2:04 am
by rbytes
I froze and crashed my laptop trying to convert a 3 minute MP3 with BIN to TXT. Took my dog for a half hour walk and came back to a white screen. Could not get back to the desktop - everything blacked out and I noticed the case was quite hot. Maybe the program was still processing, but how would I know?
I rebooted and tried a shorter binary file - a wav sound effect about 22 kb. That seemed to work, but when I opened the a.txt output file in the editor there was a white screen for maybe 20 seconds and then this. Maybe it worked OK, but I expected to see a string of hex??
Re: BIN/TXT and TXT/BIN converters
Posted: Sun Sep 10, 2017 3:07 am
by Mr. Kibernetik
rbytes wrote: ↑Sun Sep 10, 2017 1:57 am
I just used a paragraph of text copied off the web. Maybe I misunderstand your use of the .txt extender. Is the .txt file required to be only pure hex? I don't see this mentioned in the post.
These programs encode to pure HEX text and decode from it.