(C2)来自哪里 [英] Where is the  (C2) coming from

查看:51
本文介绍了(C2)来自哪里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,一段代码用 \ u00A0 替换了空格-即

For some reason a piece of code replaces spaces with \u00A0 - i.e. a Non-breaking space. This code is then used to sanitize a URL (yes I know that is very bad - in many ways). Strangely, when these are displayed in my test jsp a rogue  appears - why?

示例JSP演示该问题.

Sample JSP to demonstrate the issue.

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    <%
      String[] parameters = request.getParameterValues("p");
      if (parameters == null || parameters.length == 0) {
        parameters = new String[]{""};
      }
    %>
  </head>
  <body>
    <h1>Hello World!</h1>
    <a href='index.jsp?p=<%="Hello\u00A0there"%>'>A Link</a>
    <p><%=parameters[0]%></p>
  </body>
</html>

为什么参数在那里显示为HelloÂ? c2 是哪里来的?

Why is the parameter showing as Hello there? Where is the c2 coming from?

已添加

BTW:参数的十六进制是 48 65 6c 6c 6f c2 a0 74 68 65 72 65 ,其中显示了 c2

BTW: The hex of the parameter is 48 65 6c 6c 6f c2 a0 74 68 65 72 65 showing the c2 in-situ.

推荐答案

Rogue出现通常是表示某些内容是使用UTF-8编码的,然后又使用传统"代码页字符集重新解码的,例如ISO-8859-1或CP850或...

Rogue  appearing is most often an indication that something got encoded using UTF-8, and then decoded back again using a "traditional" code-page character set, e.g. ISO-8859-1, or CP850, or ...

这篇关于(C2)来自哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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