重音、URL 和 Firefox
我遇到了一些问题,我想知道你们中是否有人可以帮助我。
我有我的网站&数据库设置为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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取决于表单编码,通常取自包含表单的页面的编码。
%C3%A9
是ã
的正确 UTF-8 URL 编码形式。这取决于浏览器。当您在地址栏中的 URL 中放入非 ASCII 字符时:
WebKit 浏览器将它们全部编码为 UTF-8:
根据 IRI。但是,由于历史原因,IE 和 Opera 仅使用操作系统的默认系统编码对输入到查询字符串中的文本进行编码。因此,在西欧 Windows 安装(使用代码页 1252)中,您会得到:
对于系统编码中不可用的字符,IE 和 Opera 将其替换为
?
。当查询字符串中的所有字符时,Firefox 将使用系统编码,否则使用 UTF-8。可怕且不一致,但用户很少手动输入查询字符串。
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ã
.This is browser-dependent. When you put non-ASCII characters in the a URL in location bar:
WebKit browsers encode them all as UTF-8:
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:
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.