字节流和字符流 [英] Byte Stream and Character stream

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

问题描述

请解释字节流和字符流是什么。这究竟是什么意思? Microsoft Word文档是面向字节还是面向字符?

Please explain what Byte streams and Character streams are. What exactly do these mean? Is a Microsoft Word document Byte oriented or Character oriented?

谢谢

推荐答案

流是一种顺序访问文件的方式。字节流逐字节地访问文件。字节流适用于任何类型的文件,但不太适合文本文件。例如,如果文件使用的是unicode编码,并且字符用两个字节表示,则字节流将单独处理这些字符,您需要自己进行转换。

A stream is a way of sequentially accessing a file. A byte stream access the file byte by byte. A byte stream is suitable for any kind of file, however not quite appropriate for text files. For example, if the file is using a unicode encoding and a character is represented with two bytes, the byte stream will treat these separately and you will need to do the conversion yourself.

字符流将逐个字符地读取文件。需要为字符流提供文件的编码才能正常工作。

A character stream will read a file character by character. A character stream needs to be given the file's encoding in order to work properly.

虽然Microsoft Word文档包含文本,但无法使用字符流访问它(它不是文本文件)。您需要使用字节流来访问它。

Although a Microsoft Word Document contains text, it can't be accessed with a character stream (it isn't a text file). You need to use a byte stream to access it.

这篇关于字节流和字符流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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