HTML编码°度数符号额外空间

发布于 2024-09-25 07:25:48 字数 393 浏览 1 评论 0原文

  1. °F
  2. $.get("http://blah.com/go",{'TU':$(' #a').text()});
  3. IIS 服务器日志显示以下参数:
    99.5% 的时间:TU=%C2%B0F
    0.5% 的时间:TU=%C2%B0+F
  4. 服务器随后崩溃,因为它不知道“° F”是什么。无可否认,缺陷之一是我们从 DOM 和 DOM 中抓取文本。将其发送到我们的服务器。这就是我怀疑问题所在的地方,但我想了解更多。

其他信息:0.5% 的时间同时使用 IE8 和 IE8。铬合金。所有 IP 均位于哥伦比亚,这使得它看起来像是本地问题,但我们无法复制它。

想法??

  1. <div id="a">°F</div>
  2. $.get("http://blah.com/go",{'TU':$('#a').text()});
  3. IIS server logs show the following params:
    99.5% of the time: TU=%C2%B0F
    0.5% of the time: TU=%C2%B0+F
  4. server subsequently crashes because it doesn't know what '° F' is. Admittedly one of the flaws is that we are scraping text out of the DOM & sending it to our server. This is where I suspect the problem is, but I would like to understand more.

Other info: the 0.5% of the time has been both IE8 & Chrome. All IP's geolocated to Columbia, which makes it seem like a local issue, but we've been unable to replicate it.

Ideas??

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

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

发布评论

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

评论(2

庆幸我还是我 2024-10-02 07:25:48

所以问题是,有时 °F 之间有一个空格,该空格会被转换为 +,而服务器不会不接受吗?如果是这样,为什么不在发送之前去掉空格呢?

$.get("http://blah.com/go",{'TU':$('#a').text().replace(' ', '')});
// Or a more granular fix
$.get("http://blah.com/go",{'TU':$('#a').text().replace(/°\sF/, '°F')});

So the problem is that sometimes there is a space between the ° and the F, that space gets translated into a +, and the server doesn't accept it? If so, why not strip out the space before sending it?

$.get("http://blah.com/go",{'TU':$('#a').text().replace(' ', '')});
// Or a more granular fix
$.get("http://blah.com/go",{'TU':$('#a').text().replace(/°\sF/, '°F')});
悟红尘 2024-10-02 07:25:48

文本是如何放入div中的?您应该在检查服务器值之前输出它。我认为您不太可能获得相同文本的不同编码。这可能与您将其放入页面的方式有关。

另外,在获取查询字符串之前,请尝试在服务器上设置页面编码,这可能是不同的浏览器使用不同的编码。 UTF-8 是 w3.org 建议的编码。在 Java 中,您必须确保在调用从客户端读取任何内容之前设置编码。

How is the text being put into the div? You should output that before checking the server value. I don't think it's likely that you're getting a different encoding of the same text. It's probably something to do with how you're putting it into the page.

Also try setting the page encoding on the server before you get the query string, it could be that different browsers are using a different encoding. UTF-8 is the encoding suggested by w3.org. In Java, you have to make sure you set the encoding before any calls to read anything from the client.

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