重音、URL 和 Firefox

发布于 2024-10-07 04:00:19 字数 606 浏览 2 评论 0原文

我遇到了一些问题,我想知道你们中是否有人可以帮助我。

我有我的网站&数据库设置为utf8。当我在查询字符串部分输入重音符号时遇到问题 ã 会变成 %E3,但如果我在页面中使用链接或表单,它会给出 %网址中的 C3%A3

我能做些什么?

编辑:让我试着澄清一下:

我试图在我的网址(查询字符串)中使用重音字符,但我很难让它在多个浏览器上工作。某些浏览器(例如 Firefox 和 IE)会输出不同的百分比编码字符串,具体取决于我是在页面中使用表单还是在地址栏中键入重音字符。就像我在原来的问题中所说的那样,在表单中输入的 ã 会在网址中变成 %C3%A3 但如果我在表单中输入 ã地址栏,浏览器将 URL 中的值更改为 %E3

这对我来说使事情变得复杂,因为如果我得到 %E3,那么在 php/html 中我会得到一个未知字符(这是菱形问号,对吗?)

希望这有帮助 - 否则请告诉我。

I'm having some problems and I was wondering if any of you could help me.

I have my site & DB set to utf8. I have a problem when I type in accents in the query strings section ã turns to %E3, but if i use links or forms within the page it gives %C3%A3 in the url.

What can I do?

EDIT: Let me try to clarify this a bit:

I'm trying to use accented characters in my URLs (query strings) but I'm having somewhat of a hard time getting this to work across multiple browsers. Some browsers like Firefox and IE output a different percent encoded string depending on whether I'm using a form within the page or typing the accented character in the address bar. Like I said in my original question, ã inputed in a form turns to %C3%A3 in the url but if I type ã in the address bar, the browser changes that to %E3 in the url.

This complicates things for me because if I get %E3, then in php/html I get an unknown character (that is the diamond question mark, correct?)

Hopefully this helps - let me know otherwise.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恰似旧人归 2024-10-14 04:00:20

表单中输入的ã在url中变为%C3%A3

取决于表单编码,通常取自包含表单的页面的编码。 %C3%A9ã 的正确 UTF-8 URL 编码形式。

如果我在地址栏中输入 ã,浏览器会将其更改为 url 中的 %E3。

这取决于浏览器。当您在地址栏中的 URL 中放入非 ASCII 字符时:

http://www.example.com/test.p/café?café

WebKit 浏览器将它们全部编码为 UTF-8:

http://www.example.com/test.p/caf%C3%A9?caf%C3%A9

根据 IRI。但是,由于历史原因,IE 和 Opera 仅使用操作系统的默认系统编码对输入到查询字符串中的文本进行编码。因此,在西欧 Windows 安装(使用代码页 1252)中,您会得到:

http://www.example.com/test.p/caf%C3%A9?caf%E9

对于系统编码中不可用的字符,IE 和 Opera 将其替换为 ?。当查询字符串中的所有字符时,Firefox 将使用系统编码,否则使用 UTF-8。

可怕且不一致,但用户很少手动输入查询字符串。

ã inputed in a form turns to %C3%A3 in the url

Depends on the form encoding, which is usually taken from the encoding of the page that contains the form. %C3%A9 is the correct UTF-8 URL-encoded form of ã.

if I type ã in the address bar, the browser changes that to %E3 in the url.

This is browser-dependent. When you put non-ASCII characters in the a URL in location bar:

http://www.example.com/test.p/café?café

WebKit browsers encode them all as UTF-8:

http://www.example.com/test.p/caf%C3%A9?caf%C3%A9

which is IMO most correct, as per IRI. However, IE and Opera, for historical reasons, use the OS's default system encoding to encode text entered into the query string only. So on a Western European Windows installation (using code page 1252), you get:

http://www.example.com/test.p/caf%C3%A9?caf%E9

For characters that aren't available in the system encoding, IE and Opera replaces them with a ?. Firefox will use the system encoding when all the characters in the query string, or UTF-8 otherwise.

Horrible and inconsistent, but then it's pretty rare for users to manually type out query strings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文