China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-23 01:09
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Mini Converter between Hexadecimal Character Text/Binary File View 26,666 Replies 104
Floor 16 Posted 2006-07-19 15:55 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Then replace 0D0A with one or two spaces separated (2020)
Floor 17 Posted 2006-07-19 15:59 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
Then this program will lack universality.
Floor 18 Posted 2006-07-19 16:02 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
Your third point, converting carriage returns and line feeds to 0D0A characters makes it non-portable. For example, some programs have options to search for characters by line, which then won't work.

[ Last edited by GOTOmsdos on 2006-7-19 at 16:31 ]
Floor 19 Posted 2006-08-14 07:09 ·  中国 福建 厦门 电信
初级用户
Credits 147
Posts 23
Joined 2005-01-23 00:00
21-year member
UID 35557
Gender Male
Status Offline
GOTOmsdos:
bin2txt 1.0 BinToHexText convertor by grub2linux
Syntax :
bin2txt binFile textFile
binFile : binary file name.
textFile : text file name.
/killline : do not conserve RETURN & LINEFEEDs in binFile.
n : do not conserve RETURN & LINEFEADs in binFile.
add a RETURN & LINEFEED every n bytes.
/lower : in lower case.


After using it, I found a problem. When converting a bin file to a txt file, if you want to get the editor format (new line every 16 bytes), the carriage return information in the bin file must be deleted, which causes the txt2bin to be unable to restore. If there is no new line, the text is only one line, which is extremely slow to open with Notepad and not easy to browse. I wonder if there is a way to overcome this problem. It is better to directly fix the text format. Anyway, the text with a new line every sixteen bytes looks neat, and this is how the.HEX files converted by various tools are as well!
Floor 20 Posted 2006-08-14 07:18 ·  中国 福建 厦门 电信
初级用户
Credits 147
Posts 23
Joined 2005-01-23 00:00
21-year member
UID 35557
Gender Male
Status Offline
n : 不在 binFile 中保留回车符和换行符。每 n 字节添加一个回车符和换行符。
This function is like a chicken rib
Floor 21 Posted 2006-08-14 07:39 ·  中国 福建 厦门 电信
初级用户
Credits 147
Posts 23
Joined 2005-01-23 00:00
21-year member
UID 35557
Gender Male
Status Offline
Originally posted by GOTOmsdos at 2006-7-19 04:02 PM:
Your third point, converting carriage return and line feed to 0D0A characters makes it non-universal.
For example, some programs have options to search for characters by line, which won't work then..

[ Last edited by GOTO ...



This sentence is not understood. Also, having an additional option to help restore txt to bin (without causing carriage return ambiguity) is not better?

Is the modification adding a switch here? Not very familiar with C, not sure if it's this line
:(
		if(dig==0x0D) 
{

//sprintf(w,"%0X%0X",0x0D,0x0A);
fread(&dig0A,1,1,bin);
i++;
if(dig0A==0x0A)
{
if(doLine==0)
fwrite("\x0D\x0A",2,1,txt);

}


[ Last edited by mornsmile on 2006-8-14 at 07:46 ]
Floor 22 Posted 2006-08-14 11:42 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
TO mornsmile

You need to keep the carriage return and line feed, so you don't use /killline|n. If you want the editor format (newline every 16 bytes), set N to 16. If you want both the editor format (newline every 16 bytes) and the original carriage return and line feed, then after setting it up, it won't be the editor format (newline every 16 bytes)!

Whether there are line breaks or not is up to your choice.

You said:
n : do not conserve RETURN & LINEFEEDs in binFile.
add a RETURN & LINEFEED every n bytes.

This function is like a鸡肋 "

Can you please explain the reason?
Floor 23 Posted 2006-08-15 00:44 ·  中国 福建 厦门 电信
初级用户
Credits 147
Posts 23
Joined 2005-01-23 00:00
21-year member
UID 35557
Gender Male
Status Offline
What I mean is not to convert the 0D0A in bin to line break symbols. Otherwise, after /killline|n, it cannot be restored. Even if there is an editor, the format is not the original binary information, so it is meaningless. Of course, I mean when processing bin containing 0D0A.
Floor 24 Posted 2006-08-15 00:52 ·  中国 福建 厦门 电信
初级用户
Credits 147
Posts 23
Joined 2005-01-23 00:00
21-year member
UID 35557
Gender Male
Status Offline
Floor 25 Posted 2006-08-15 00:55 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
n : do not conserve RETURN & LINEFEEDs in binFile.
add a RETURN & LINEFEED every n bytes.

The above is a useful feature.

If you want to keep the carriage return and line feed, then of course you don't need /killline, just keep it.
If you remove this, then if you need this function, isn't it a pity?
Floor 26 Posted 2006-08-15 01:13 ·  中国 福建 厦门 电信
初级用户
Credits 147
Posts 23
Joined 2005-01-23 00:00
21-year member
UID 35557
Gender Male
Status Offline
I mean, I don't know if I made it clear enough.
Just don't remove the original carriage returns.
Convert the text
0000544C4F5353206572726F72
00000053494E47206572726F72
00000000444F4D41494E206572726F72

to
0000544C4F5353206572726F720D0A00000053494E47206572726F720D0A00000000444F4D41494E206572726F72


[ Last edited by mornsmile on 2006-8-15 at 01:15 ]
Floor 27 Posted 2006-08-15 01:19 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
Oh, that's the meaning..
If you think this is useful, then it can be added...
Floor 28 Posted 2006-08-15 01:22 ·  中国 福建 厦门 电信
初级用户
Credits 147
Posts 23
Joined 2005-01-23 00:00
21-year member
UID 35557
Gender Male
Status Offline
This is the original hexadecimal code. Please help modify it, expert.
Floor 29 Posted 2006-08-15 01:25 ·  中国 福建 厦门 电信
初级用户
Credits 147
Posts 23
Joined 2005-01-23 00:00
21-year member
UID 35557
Gender Male
Status Offline
Share your source code too:)
Compiled with BCB is only 9k
Floor 30 Posted 2006-08-15 01:29 ·  中国 福建 厦门 电信
初级用户
Credits 147
Posts 23
Joined 2005-01-23 00:00
21-year member
UID 35557
Gender Male
Status Offline
There is still confusion about the role of /killline|n in txt2bin.
Forum Jump: