I get a string from my HTML page into my Java HTTPServlet. On my request I get ASCII codes that display Chinese characters:
"& #21487;& #20197;& #21578;& #35785;& #25105;" (without the spaces)
How can I transform this string into Unicode?
HTML code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Find information</title>
<link rel="stylesheet" type="text/css" href="layout.css">
</head>
<body>
<form id="lookupform" name="lookupform" action="LookupServlet" method="post" accept-charset="UTF-8">
<table id="lookuptable" align="center">
<tr>
<label>Question:</label>
<td><textarea cols="30" rows="2" name="lookupstring" id="lookupstring"></textarea></td>
</tr>
</table>
<input type="submit" name="Look up" id="lookup" value="Look up"/>
</form>
Java code:
request.setCharacterEncoding("UTF-8");
javax.servlet.http.HttpSession session = request.getSession();
LoginResult lr = (LoginResult) session.getAttribute("loginResult");
String[] question = request.getParameterValues("lookupstring");
If I print question[0] then I get this value: "& #21487;& #20197;& #21578;& #35785;& #25105;"