none
Encoding issue for a textbox. RRS feed

  • Question

  • I am developing website, and I need to allow for a user to input Chinese characters in textbox. So I need to ensure that I can accept the text encoded as UTF-8 via JavaScript . For testing purposes, I have an alert box being popped up with the text I enter every time a search is done, and when some Chinese text is entered in, I get 'undefined' returned. With English the word I entered is returned back, as expected. How can I ensure that text in the textbox is encoded with UTF-8?
    Thursday, February 23, 2017 7:35 AM

All replies

  • Is this ASP.NET?

    If it is you would be better to post in that forum (or a moderator could move this post).

    In general though, textboxes are always going to be Unicode (full Unicode16) anyway. And when that data is transmitted back via a webpage or whatever it should get encoded as UTF-8 (I believe). But this may depend on your web page encoding etc.

    So it would be helpful if you showed some code to demonstrate your problem. It could just be your debug/alert box that's actually in error.



    • Edited by RJP1973 Thursday, February 23, 2017 8:26 AM
    Thursday, February 23, 2017 8:26 AM
  • Hi ,

    Since you don't post code here. Here are my suggestions.

    Please Make sure of the following:

    • Your HTML and JS documents are UTF-8 encoded.
    • You are sending a Content-type header with appropriate (UTF-8) value for both your HTML and JS files.
    • The meta tag charset defined in your HTML is also, appropriately, UTF-8.
    • Avoid using the built-in escape method; it is not UTF-8 aware.

    Have a nice day!

    Kristin


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, February 23, 2017 9:32 AM