Windows和Unix的路径分隔符 [英] Path separator for Windows and Unix

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

问题描述

在Windows或Unix中是否存在不能用作路径的一部分的特殊字符,我可以将其用作分隔符?

Is there any special character that cannot be a part of the path in Windows or Unix that I can use it as a separator?

推荐答案

Wikipedia有用地列出了保留的不同文件系统的字符. NTFS和POSIX都不接受文件名中的null或斜杠(/)字符.斜杠字符显然不是一个好的分隔符,因为它在POSIX路径中很常见,因此也许可以使用null.

Wikipedia helpfully lists the reserved characters for different filesystems. Neither NTFS nor POSIX will accept the null or slash (/) characters in filenames. The slash character is obviously not a good separator, since it's common in POSIX paths, so maybe you could use null.

当然,null不适用于所有情况(例如,在打印时通常不可见),在这种情况下,您可能必须使用某种

Of course null isn't suited to all situations (e.g. it isn't usually visible when printed), in which case you might have to use some sort of escaping scheme.

旨在跨不同平台工作的Java甚至没有尝试找到通用的路径分隔符.相反,每个平台都有自己的角色,可通过 API .

Java, which aims to work across different platforms, doesn't even try to find a common path separator. Instead each platform has its own character, accessible through an API.

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

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