Text character encoding

I have a webpage with a text area for user input. When reading the textarea value in javascript to compare it with the previous value, I get the value with the encoding of the platform ('ä' =>% e4), while my value from the database is encoded in UTF-8 ('ä' => $ % c3% a4). The webpage encoding is UTF-8, using the xml encoding attribute plus meta encoding. The browser also says that it uses UTF-8 encoding, but still textbox.value is in platform encoding.

Does anyone have an idea how I can say that the user agent returns textarea.value as UTF-8?

+6
source share
1 answer

Will the following solutions be for you?

function encode_utf8( s )
{
   return unescape( encodeURIComponent( s ) );
}

where do you call encode_utf8with the value of your text field? This sentence from another SO answer is found here . Not exactly the same problem, but the solution may be applicable.

0
source

All Articles