BIN/TXT and TXT/BIN converters

Post Reply
User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

BIN/TXT and TXT/BIN converters

Post 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")

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: BIN/TXT and TXT/BIN converters

Post 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:
Attachments
Screenshot (34).png
Screenshot (34).png (61.11 KiB) Viewed 2471 times
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: BIN/TXT and TXT/BIN converters

Post by Mr. Kibernetik »

What file are you converting which gives this error? Can you attach it to test?

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: BIN/TXT and TXT/BIN converters

Post 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.
The only thing that gets me down is gravity...

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: BIN/TXT and TXT/BIN converters

Post 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??
Attachments
Text.PNG
Text.PNG (377.14 KiB) Viewed 2467 times
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: BIN/TXT and TXT/BIN converters

Post 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.

Post Reply