设置文件名编码 [英] Setting file name encoding

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

问题描述

我有一个定义的编码(utf8)的输入文件,从中创建不同的文件,其名称和内容(再次是utf8)是从该输入文件获取的。

I have an input file in a defined encoding (utf8) from which I create different files whose names and content (again utf8) are taken form that input file.

我的问题是,一个特定的Windows系统,创建的文件没有正确的字符。这些文件的内容是完全可读的,但它们的名字不是。
而不是Ü.xml,该文件名称为├£.xml

My problem is that one a particular windows system, the files created do not have the correct characters. The content of these files is perfectly readable, but their names not. Instead of Ü.xml, the file has the name ├£.xml.

在其他Windows系统上,一切正常。

On other Windows systems everything works fine.

文件内容的编码可以在 OutputStreamWriter 的第二个参数,但文件名的编码不能在中设置新的文件(名称)似乎。

The file content's encoding can be set in OutputStreamWriter's second argument, but the file name's encoding can not be set in new File(name) is seems.

谢谢。

推荐答案

看到两个字符,应该有一个UTF-8多字节字符ü。该Windows似乎没有UTF-8作为文件编码。一个UTF-8文件被复制到该系统上,就像打开zip文件一样。

Seeing two chars where there should be one UTF-8 multi-byte char ü. that Windows does not seem to have UTF-8 as file encoding. And a UTF-8 file was copied onto that system, like unpacking a zip file.

System.getProperty(file.encoding)应该给平台编码。也许,远程可想象的,这是一些奇怪的情况不被Java覆盖。 Windows,像压缩目录,或第二个外部磁盘格式化为非UTF-8功能的文件系统。

System.getProperty("file.encoding") should give the platform encoding. Maybe, remotely imaginable, it is some odd case not covered by Java resp. Windows, like a compressed directory, or a second external disk formatted with a non-UTF-8 capable file system.

这篇关于设置文件名编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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