(C2)来自哪里 [英] Where is the  (C2) coming from
问题描述
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屋!