0
votes

I have made all the necessary changes for database variable to UTF8

  • character_set_client utf8
  • character_set_connection utf8
  • character_set_database utf8
  • character_set_filesystem binary
  • character_set_results utf8
  • character_set_server utf8
  • character_set_system utf8

Also added the included the tag on jsp:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 

But when a non English text is entered it get converted and store in form of html entities i.e #&number format

I want to enter it in Unicode codepoint format like \u6709 without any java code converter program:

<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
  <form id="storeMsgForm"  method="post" action="createnewmessage" >
  <input type="text" name="msg_code">
   <input type="text" name="message">
   <input type="submit" id="saveEmployee" class="btn btn-primary" value="Save">
  </form>

  <c:forEach var="listvalue" items="${allMsg.allmessage}">
  ${listvalue.msg_code} 
  ${listvalue.message}
  <br/>
  </c:forEach>

<% 
 if (request.getCharacterEncoding() == null) {
        request.setCharacterEncoding("UTF-8");

    }
  %> 
</body>
</html>
2

2 Answers

0
votes

The browser translated the special Unicode code points in input to HTML entities because of the form missing an accept-charset of UTF-8. The browser thinks the posted form results cannot be in UTF-8 for the server.

<form id="storeMsgForm"  method="post" action="createnewmessage" accept-charset="UTF-8">
0
votes

Search http://mysql.rjweb.org/doc.php/charcoll for references to Java and Spring and JSP.

दà¥à¤µà¤¨à¤¾à¤à¤°à¥ looks like Mojibake for Devanagari; is that the language you are trying to use?

When trying to use utf8/utf8mb4, if you see Mojibake, check the following.

  • The bytes to be stored need to be utf8-encoded.
  • The connection when INSERTing and SELECTing text needs to specify utf8 or utf8mb4.
  • The column needs to be declared CHARACTER SET utf8 (or utf8mb4).
  • HTML should start with <meta charset=UTF-8>.
  • Use <form method="post" ... accept-charset="UTF-8"> if a 'form' is involved.