UNIX和Windows文件之间的区别 [英] Differences between unix and windows files

查看:281
本文介绍了UNIX和Windows文件之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是正确的假设"Windows文件"之间的唯一区别是和"unix文件"是换行符吗?

Am I correct in assuming that the only difference between "windows files" and "unix files" is the linebreak?

我们有一个系统已从Windows机器移至UNIX机器,并且格式有问题.

We have a system that has been moved from a windows machine to a unix machine and are having troubles with the format.

在将文件传递到我们的传输系统"中的系统之前,我需要在Unix/Windows之间自动进行翻译.我可能需要确定当前格式的东西,以及将其转换为其他格式的东西. 如果仅仅是换行符,那是最大的区别,那么我正在考虑仅使用java.io读取文件.据我所知,他们能够使用readLine来处理这两种情况.然后只需将每行写回

I need to automate the translation between unix/windows before the files get delivered to the system in our "transportsystem". I'll probably need something to determine the current format and something to transform it into the other format. If it's just the newline thats the big difference then I'm considering just reading the files with the java.io. As far as I know, they are able to handle both with readLine. And then just write each line back with

while (line = readline)
    print(line + NewlineInOtherFormat)
....


摘要:

samjudson :

这只是文本文件的区别,其中UNIX使用单个换行(LF)表示新行,Windows使用回车/换行(CRLF),而Mac仅使用CR. /i>

This is only a difference in text files, where UNIX uses a single Line Feed (LF) to signify a new line, Windows uses a Carriage Return/Line Feed (CRLF) and Mac uses just a CR.

Cebjyre 详细阐述:

OS X使用LF,与UNIX相同-MacOS 9和更低版本的确使用CR.

Mo

国家字符的字符编码也可能有所不同.没有"unix-encoding".但是许多linux变体都使用UTF-8作为默认编码. Mac OS(也是Unix)使用自己的编码(宏).我不确定Windows默认编码是什么.

McDowell

除了换行符以外,如果在Windows上将文件视为Unicode,则字节顺序标记也会引起问题.

Cheekysoft

但是,您可能遇到的另一组问题可能与单字节/多字节字符编码有关.如果您看到奇怪的意外字符(不在行尾),则可能是原因.尤其是如果您看到方框,问号,上下颠倒的问号,多余的字符或意外的重音符号.

Sadie

在UNIX上,以.开头的文件.隐藏.在Windows上,这是一个文件系统标志,您可能无法轻松访问.这可能会导致本应隐藏的文件现在在客户端计算机上变得可见.

On unix, files that start with a . are hidden. On windows, it's a filesystem flag that you probably don't have easy access to. This may result in files that are supposed to be hidden now becoming visible on the client machines.

文件权限在两者之间有所不同.当您将文件复制到UNIX系统上时,您可能会发现文件现在属于进行复制的用户,并且权限有限.您需要使用chown/chmod来确保正确的用户可以访问它们.

File permissions vary between the two. You will probably find, when you copy files onto a unix system, that the files now belong to the user that did the copying and have limited rights. You'll need to use chown/chmod to make sure the correct users have access to them.

有一些工具可以解决该问题:

There exists tools to help with the problem:

pauldoo

如果您仅对文本文件的内容感兴趣,则是的,行尾不同.看一下dos2unix之类的东西,这可能对您有所帮助.

Cheekysoft

正如pauldoo所建议的那样,dos2unix之类的工具可能非常有用.请注意,这些文件可能以fromdos或tofrodos的形式出现在您的linux/unix系统上,甚至可能以通用工具箱的重新编码形式出现.

有关Java编码的帮助

Help for java coding

Cheekysoft

在写入文件或从文件中读取(由您控制​​)时,通常值得指定要使用的编码,因为大多数Java方法都允许这样做.但是,确保系统区域设置匹配也可以节省很多麻烦

推荐答案

这只是文本文件的区别,其中UNIX使用单个换行(LF)表示新行,Windows使用回车/换行(CRLF),而Mac仅使用CR.

This is only a difference in text files, where UNIX uses a single Line Feed (LF) to signify a new line, Windows uses a Carriage Return/Line Feed (CRLF) and Mac uses just a CR.

二进制文件应该没有区别(即Windows机器上的JPEG将与unix框上的相同JPEG逐字节地存储)

Binary files there should be no difference (i.e. a JPEG on a windows machine will be byte for byte the same as the same JPEG on a unix box.)

这篇关于UNIX和Windows文件之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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