URL转义Internet Explorer的中文/日文Unicode字符 [英] URL Escaping Chinese/Japanese Unicode Characters for Internet Explorer

查看:209
本文介绍了URL转义Internet Explorer的中文/日文Unicode字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我处理的几个URL中的URL-escape(百分号编码)非ascii字符。我正在使用一个Flash应用程序,从这些URL加载资源,如图像和声音片段。由于文件名可以包含非ASCII字符,如下所示:
日本语.jpg
我通过UTF-8对字符进行编码,而然后百分比转义unicode字节,以获得以下内容:



%E6%97%A5%E6%9C%AC%E8%AA %9E.jpg



这些文件名在Internet Explorer以外的浏览器中运行应用时工作正常 - 我尝试过Firefox,Safari和Chrome。但是当我在IE中启动应用程序(尝试6和8),并尝试加载声音片段时,我得到:
错误#2044:未处理的ioError ,并且URL已被损坏到如下所示:



æ¥æ¬èª.jpg

任何关于如何解决这个问题的想法?这只是使用本地文件系统URL测试驱动Flash应用程序。
我也注意到,Internet Explorer无法找到如下文件:
file:/// C:/%E6%97%A5%E6% 9C%AC%E8%AA%9E.jpg ,尽管Chrome / Firefox将对其进行解码,并对文件加载路径



C:\日本语.jpg



编辑



我认为我的问题与以下ActionScript代码片段中遇到的问题相同:

  import flash.display.Loader; 
import flash.net.URLRequest;
...
var ldr:Loader;
var req:URLRequest = new URLRequest(日本语.jpg);
ldr = new Loader();
ldr.load(req);

使用字符串日本语.jpg 将在IE中工作,而使用字符串%E6%97%A5%E6%9C%AC%E8%AA%9E.jpg 适用于其他浏览器。我需要的是一种可以在所有浏览器中运行的单一形式。我尝试过%u 编码并将http请求头设置为 Content-Type:text / html; charset = utf-8 ,没有运气的百分比转义或非转义形式。

解决方案

文件://协议取决于您的操作系统区域设置,如果您的系统设置未设置为中文,但不能让IE执行此操作。


I'm trying to URL-escape (percent-encode) non-ascii characters in several URLs I'm dealing with. I'm working with a flash application that loads resources like images and sound clips from these URLs. Since the filenames can contain non-ascii characters, like so: 日本語.jpg I escape them by utf-8 encoding the characters, and then percent-escaping the unicode bytes, to get the following:

%E6%97%A5%E6%9C%AC%E8%AA%9E.jpg

These filenames work fine when I run the app in any browser other than Internet Explorer - I've tried Firefox, Safari and Chrome. But when I launch the app in IE (tried both 6 and 8) and it tries to load the sound clip, I get: Error #2044: Unhandled ioError, and the URL has been corrupted to something like:

æ¥æ¬èª.jpg

Any thoughts on how to fix this? This is just test-driving the flash app with local filesystem URLs. I've also noticed that Internet explorer isn't able to locate a file such as: file:///C:/%E6%97%A5%E6%9C%AC%E8%AA%9E.jpg, though Chrome / Firefox will decode it and load just fine for a file with the path

C:\日本語.jpg

edit

I think my problem is the same as the one encountered in the following ActionScript code fragment:

import flash.display.Loader;
import flash.net.URLRequest;
...
var ldr:Loader;
var req:URLRequest = new URLRequest("日本語.jpg");
ldr = new Loader();
ldr.load(req);

Using the string 日本語.jpg will work in IE, while using the string %E6%97%A5%E6%9C%AC%E8%AA%9E.jpg works in other browsers. What I need is a single form that will work in all browsers. I have tried the %u encoding and setting the http request header to Content-Type: text/html; charset=utf-8 with no luck in either percent-escaped or unescaped form.

解决方案

file:// protocol depends on your OS region settings, if your system settings doesn't set to chinese but english, you can't let IE do this.

这篇关于URL转义Internet Explorer的中文/日文Unicode字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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