阿拉伯文件名转换为问号
我有一个 Spring 应用程序,其形式之一是用来上传 Excel 文件的。
该应用程序将文件保存在硬盘上,并为用户提供再次下载的链接。
如果文件名用英文书写,则一切正常,但如果文件名包含阿拉伯字符,则文件阿拉伯字符将转换为问号。
很明显,问题与字符编码有关,但我无法准确检测问题出在哪里。
以下是系统结构和配置:
- 操作系统:Centos
- 应用服务器:Tomcat
server.xml 中的连接器配置
[连接器端口=“8009”协议=“AJP/1.3”redirectPort=“8443”URIEncoding=“UTF-8”]
I have a spring application in one of the forms the use supposed to upload an excel file.
The application saves the file on the hard desk and provide a link to the user to download it again.
If the file name is written in English every thing goes OK but if the file name contains Arabic characters, the file Arabic characters are converted into question marks.
It is clear that the problem is related to character encoding but I can not detect where is the problem exactly.
Here is the system structure and the configurations:
- Operating system : Centos
- Application server : Tomcat
connector configs in server.xml
[Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
浏览这两页:
每个软件开发人员绝对必须了解 Unicode 和字符集的绝对最低限度(没有借口!) - 作者:Joel Spolsky
和
阿拉伯语 unicode 块的维基百科页面
也许这些会有所帮助......
Go through these two pages:
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) - by Joel Spolsky
and
the Wikipedia page for the unicode block for Arabic
Maybe these will help...
你必须知道什么是阿拉伯字符的字符集。
如果您不知道,您可以尝试使用 UTF-16。
使用的代码如下:
尽情享受吧。
You have to know what's char-set of Arabic character.
If you don't know, you can try with UTF-16.
The code to use is following:
Enjoy yourself.
在 Windows 控制面板中,转到区域选项和区域选项。在“管理”选项卡中,选择“非 Unicode 程序的语言”,选择区域阿拉伯语言。
In Windows Control panel, go to Regional Option & in Administrative Tab, select in Langauge of Non Unicode programme, Select the regional Arabic Langauge.
我认为它的阿拉伯语语言不支持您的系统语言,所以请尝试这个。
byte[] utf8Bytes = ("阿拉伯语字符串").getBytes("阿拉伯语");
参数 = new Object[]{new String(utf8Bytes,"UTF8")};
System.out.println(参数);
I think its arabic lang not support your system's language so try this.
byte[] utf8Bytes = ("Arabic String").getBytes("arabic");
argument = new Object[]{new String(utf8Bytes,"UTF8")};
System.out.println(argument);