Problems sending character ® via AJAX request

I have a simple asp.net web application that uses YUI to request an Ajax. An application reads text from a text field and sends an AJAX request to the server. Below is the code

<body> <form id="form1" runat="server"> <div> <input id="txt" name="txt" type="text" value="[Enter some value]" /> <input id="btn" type="button" value="button" /> </div> <div id="out"></div> </form> </body> 

Below is a client script that initializes an Ajax request

 YAHOO.util.Event.onDOMReady(function() { YAHOO.util.Event.addListener("btn", "click", function(evt) { var url = "Server.aspx?type=test&txt=" + document.getElementById("txt").value; var btn = document.getElementById("out"); var cObj = YAHOO.util.Connect.asyncRequest('GET', url, { success: function(o) { btn.innerHTML += "<div>" + o.responseText + " = " + o.responseText.charCodeAt(0) + "</div>"; }, failure: function(o) { confirm("Its failure"); }, cache: false }); }); }); 

What I do in the application is a sign entered by the user, save it in db and write it in the Ajax response. The system does not support Unicode (database).

Now my problem is that when the symbol "Registered" ® (0174) is entered in the text box and sent to the server, I get # 65533, which is not what the user entered into the text box. In addition, this character is not a Unicode character, then why is this behavior.

+6
source share
2 answers

Forget about configuration problems, your problem is probably related to your editor and the file encoding used to save your files. It is not enough to set the character encoding, sometimes it doesn’t even matter, you need to save the files themselves in an encoding that supports a character set, for example: utf-8 without a specification, get an editor where you can see this information. Of course, a lot can happen between your web server, the database server (assuming you use it) and the client. Checkout the default character on the web server whe, the database and the file encoding your editor is used to save the files.

+2
source

Removing from the tags you set, is the backend programmed in asp.net? Check what encoding you work there (see, for example, here ). Your problem sounds like it will be different from what you deliver to the client (see server settings).

+1
source

Source: https://habr.com/ru/post/903116/


All Articles