文本到二进制 [英] text to binary

查看:83
本文介绍了文本到二进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将通过键盘输入的文本转换为二进制格式?

我应该先将文本的每个字母转换为ASCII然后

binary ???


这种方法是否正确?请指教。


非常感谢。


问候,

Raghu

how do i convert a text entered through keyboard into a binary format?
Should I first convert each letter of the text to ASCII and then
binary???

Is this method correct? Please advise.

Thanks a lot.

Regards,
Raghu

推荐答案

raghu说:
raghu said:

如何转换通过键盘输入的文字
how do i convert a text entered through keyboard



C并不保证你是一个键盘。大概你的意思是标准输入

stream。

C doesn''t guarantee you a keyboard. Presumably you mean the standard input
stream.


变成二进制格式?
into a binary format?



您想要哪种二进制格式?

Which binary format would you like?


我应该先将文本的每个字母转换为ASCII然后

二进制???


这种方法是否正确?请指教。
Should I first convert each letter of the text to ASCII and then
binary???

Is this method correct? Please advise.



您需要更加具体地了解输入的性质以及相应输出的所需特性。

。 >

-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然放弃了www)

You need to be a lot more specific about the nature of your input and the
desired characteristics of the corresponding output.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)


我的意思是通过使用scanf语句,如果我给短信(包括

只有空格而不是特殊字符)可以转换成二进制1'的

和0'。

希望现在我很清楚


Richard Heathfield写道:
I mean by using scanf statement if i give the text message (including
only spaces not special characters) can that be converted to binary 1''s
and 0''s.

Hope now i''m clear

Richard Heathfield wrote:

raghu说:
raghu said:

如何转换通过键盘输入的文本
how do i convert a text entered through keyboard



C并不保证你是键盘。大概你的意思是标准输入

stream。


C doesn''t guarantee you a keyboard. Presumably you mean the standard input
stream.


变成二进制格式?
into a binary format?



您想要哪种二进制格式?


Which binary format would you like?


我应该先将文本的每个字母转换为ASCII然后

二进制???


这种方法是否正确?请指教。
Should I first convert each letter of the text to ASCII and then
binary???

Is this method correct? Please advise.



您需要更加具体地了解输入的性质以及相应输出的所需特性。
>

-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然是放弃www)


You need to be a lot more specific about the nature of your input and the
desired characteristics of the corresponding output.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)


" raghu"写道:
"raghu" writes:

如何将通过键盘输入的文本转换为二进制格式?

我应该先将文本的每个字母转换为ASCII然后

二进制???


这种方法是否正确?请指教。
how do i convert a text entered through keyboard into a binary format?
Should I first convert each letter of the text to ASCII and then
binary???

Is this method correct? Please advise.



否。短语二进制文件在C语言的背景下,这是一个非常糟糕且误导性的选择。二进制文件是CR和LF在外部介质(文件)和RAM中具有相同编码的文件。所谓的

" text"当文件被读取或写入时,文件在< CR>< LFor< LF>< CRand''\ n''之间静默转换。 (注意''n''具有与

LF相同的ASCII编码。)


什么是ASCII?这是一个正式的定义,如果你愿意,可以在拉丁字母表中的某些字形 - 和二进制代码之间进行映射。如果二进制文件没有被滥用,那么它已经是一个二进制文件。应始终保存一个完全由ASCII字符组成的
的文件,并将其作为非二进制文件检索到
。关于总是的常见警告这是一个很麻烦的词。


如果这让你感到困惑,那么在google群组上进行搜索,你会发现

较旧的帖子讨论这个问题..


No. The phrase "binary file" in the context of the C language was a very
poor and misleading choice. A binary file is one in which CR and LF have
the same encoding in an external medium (file) and in RAM. A so-called
"text" file silently transforms between <CR><LFor <LF><CRand ''\n'' when
the file is read or written. (Note that ''n'' has the same ASCII encoding as
LF.)

What is ASCII? It is a formal definition, mapping if you like, between
certain glyphs in the latin alphabet -mostly - and a binary code. It already
*is* a binary file, if the word binary is not misused. A file that consists
entirely of ASCII characters should always be saved and
retrieved as a non-binary file. With the usual caveats about "always" being
a troublesome word.

If this leaves you confused, do a search on google groups, you will find
older posts discussing this problem..



这篇关于文本到二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆