![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-07 12:08 |
48,040 topics / 350,125 posts / today 0 new / 48,252 members |
| DOS开发编程 & 发展交流 (开发室) » Mini Converter between Hexadecimal Character Text/Binary File |
| Printable Version 27,644 / 104 |
| Floor1 GOTOmsdos | Posted 2006-07-18 15:14 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
A mini converter for hexadecimal character text/binary file mutual conversion that I just wrote to solve a netizen's problem.
(Because there is a switch for selective processing of carriage return and line feed, and 0D 0A can be either binary data to be processed or carriage return and line feed, so although it's a small thing, it took some thought during writing..) It's very helpful for learning character and numerical processing... Added simple input detection and help. Updated. [ Last edited by GOTOmsdos on 2006-7-20 at 21:36 ] Attachments txt_bin.rar (35 KiB) |
|
| Floor2 zh159 | Posted 2006-07-18 15:52 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
The bin2txt is incorrect. The hexadecimal display of the second 0 should be 30, but after conversion it becomes
Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F And A, B, C, D, E, F should all be in uppercase The 0D0A that should have been wrapped should be used as the main line break symbol (I need one that directly converts BIN to TXT, without deleting the 0D0A line break symbol inside, using the 0D0A line break symbol as the segment identification mark) I used UPXShell to encrypt and compress TXT2BIN, reducing it to 17.5k, and it can work normally in the command prompt ^_^ [ Last edited by zxcv on 2006-7-18 at 16:31 ] |
|
| Floor3 GOTOmsdos | Posted 2006-07-18 17:39 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
Modified... Now make the characters uppercase.
[ Last edited by GOTOmsdos on 2006-7-18 at 17:42 ] |
|
| Floor4 GOTOmsdos | Posted 2006-07-18 17:57 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
It's done, go download it.
|
|
| Floor5 zh159 | Posted 2006-07-18 21:08 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
010102030405060708090A0B0C0D0E0F After converting txt2bin to bin, there is no problem. 01 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F But when converting this bin back to txt using bin2txt, the txt is incorrect. It should be that there is a problem with data judgment (0X can only be recognized as X). [ Last edited by zxcv on 2006-7-18 at 21:10 ] |
|
| Floor6 GOTOmsdos | Posted 2006-07-18 21:54 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
0X can only be recognized as X?
There is no 0X in hexadecimal. I tested and there is no problem, you check it, character [ Last edited by GOTOmsdos on 2006-7-18 at 22:18 ] |
|
| Floor7 GOTOmsdos | Posted 2006-07-18 22:02 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
You post the things that went wrong.
|
|
| Floor8 GOTOmsdos | Posted 2006-07-18 22:09 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
Oh, I found out that in BIN2TXT, I handled 0D 0A separately. There's a problem with this. I'll make a change.
[ Last edited by GOTOmsdos on 2006-7-18 at 22:20 ] |
|
| Floor9 zh159 | Posted 2006-07-18 22:33 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
You directly use text 1.txt:
000102030405060708090A0B0C0D0E0F And BAT: @echo off You'll know when you test it. The correct 2.txt is: 000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F Note: For txt2bin, there's no need to consider converting 0D0A line breaks into the bin (after TXT is converted to BIN, there's no need to retain carriage returns and line feeds in the BIN; the last txt2bin program you made included 0D0A, which is not needed (the one at three o'clock in the afternoon is normal)), and 0D0A line breaks have no meaning in the BIN generated after txt2bin. And for bin2txt, after BIN is converted to TXT, if there are 0D0A line breaks in the BIN data, they need to be converted to line breaks in the TXT (this BIN file was not generated by txt2bin, so it may contain 0D0A line breaks). Actually, it's: txt2bin doesn't need to consider 0D0A line breaks, just write the characters into the BIN; bin2txt needs to consider 0D0A line breaks in the BIN to create line breaks in the TXT (a switch parameter can be considered to ignore 0D0A line breaks). [ Last edited by zxcv on 2006-7-18 at 23:53 ] |
|
| Floor10 GOTOmsdos | Posted 2006-07-19 00:03 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
It's fixed. You can go and download it...
|
|
| Floor11 GOTOmsdos | Posted 2006-07-19 00:12 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
Now I have all retained the carriage return and line feed characters.
Because, only in this way can mutual conversion and mutual restoration be achieved. When converted to BIN, if there are no line feed characters, it cannot be restored to TXT. If you don't retain them, just use the one uploaded last time. |
|
| Floor12 zh159 | Posted 2006-07-19 02:30 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
I think a switch parameter should be added to turn on/off whether line breaks are used (default is on)
Thanks a lot for GOTOmsdos's help [ Last edited by zxcv on 2006-7-19 at 09:18 ] |
|
| Floor13 GOTOmsdos | Posted 2006-07-19 12:00 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
Then I'll add this function.. Wait for the update..
|
|
| Floor14 zh159 | Posted 2006-07-19 14:53 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
The switch parameters of bin2txt are best set to 3 types:
1. Default on: Newline with 0D0A line feed characters 2. Off parameter: Ignore 0D0A line feed characters and do not wrap lines 3. Direct write: Directly write 0D0A line feed characters as original characters (all hexadecimal data is written, which can be used as a reference symbol for data segmentation) |
|
| Floor15 GOTOmsdos | Posted 2006-07-19 15:20 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
Has been updated:
1 No parameters, keep carriage return and line feed 2 /killline Remove carriage return and line feed 3 n Add a line feed every n hexadecimal characters What you said "Direct writing: directly write the 0D0A line feed character as it is (all hexadecimal data is written, which can be used as a data segmentation reference symbol)" This is incompatible with most usages. |
|
| 1 2 3 4 … 7 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |