Character encoding of textarea [closed]
I have a web page with a text area for the user to enter data. When reading the value of the textarea in javascript to compare it to the prior value I get the value with platform encoding ('ä'=>%e4) while my value from the database is in UTF-8 encoding ('ä'=>$%c3%a4). The webpage encoding is UTF-8, using the xml encoding attribute plus meta charset. The browser also says it is using UTF-8 encoding, but still textbox.value is in platform encoding.
Does anyone have an idea how I can tell the user agent to return textarea.value as UTF-8?
html character-encoding textarea
closed as off-topic by deceze♦ Jan 20 at 14:19
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – deceze
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I have a web page with a text area for the user to enter data. When reading the value of the textarea in javascript to compare it to the prior value I get the value with platform encoding ('ä'=>%e4) while my value from the database is in UTF-8 encoding ('ä'=>$%c3%a4). The webpage encoding is UTF-8, using the xml encoding attribute plus meta charset. The browser also says it is using UTF-8 encoding, but still textbox.value is in platform encoding.
Does anyone have an idea how I can tell the user agent to return textarea.value as UTF-8?
html character-encoding textarea
closed as off-topic by deceze♦ Jan 20 at 14:19
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – deceze
If this question can be reworded to fit the rules in the help center, please edit the question.
This questions could use some clarification. What server side language are you using to read the database? How exactly are you encoding the webpage? Are you using "meta content="?
– mmcglynn
Sep 25 '12 at 14:25
1
Thank you for your comment, but as this is almost a year old, I meanwhile solved the problem in a different way. To answer the question anyways: The XHTML page is encoded in UTF-8 using the xml encoding attribute plus <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>. Even when I entered text into the text field manually, its value was always platform-encoded.
– Alexander Reifinger
Sep 27 '12 at 12:19
1
…Then you should answer your own question so it is no longer marked 'unanswered'.
– rhavin
Jan 20 '14 at 14:15
Well, technically, it is unanswered - even though the answer no longer bothers (but interests) me. Anyway, if anyone answers with "This is intended behaviour" or "This cannot be reproduced" or "You are a moron", I will accept this as a valid answer :-)
– Alexander Reifinger
Jan 21 '14 at 16:09
add a comment |
I have a web page with a text area for the user to enter data. When reading the value of the textarea in javascript to compare it to the prior value I get the value with platform encoding ('ä'=>%e4) while my value from the database is in UTF-8 encoding ('ä'=>$%c3%a4). The webpage encoding is UTF-8, using the xml encoding attribute plus meta charset. The browser also says it is using UTF-8 encoding, but still textbox.value is in platform encoding.
Does anyone have an idea how I can tell the user agent to return textarea.value as UTF-8?
html character-encoding textarea
I have a web page with a text area for the user to enter data. When reading the value of the textarea in javascript to compare it to the prior value I get the value with platform encoding ('ä'=>%e4) while my value from the database is in UTF-8 encoding ('ä'=>$%c3%a4). The webpage encoding is UTF-8, using the xml encoding attribute plus meta charset. The browser also says it is using UTF-8 encoding, but still textbox.value is in platform encoding.
Does anyone have an idea how I can tell the user agent to return textarea.value as UTF-8?
html character-encoding textarea
html character-encoding textarea
asked Nov 10 '11 at 11:54
Alexander ReifingerAlexander Reifinger
335216
335216
closed as off-topic by deceze♦ Jan 20 at 14:19
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – deceze
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by deceze♦ Jan 20 at 14:19
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – deceze
If this question can be reworded to fit the rules in the help center, please edit the question.
This questions could use some clarification. What server side language are you using to read the database? How exactly are you encoding the webpage? Are you using "meta content="?
– mmcglynn
Sep 25 '12 at 14:25
1
Thank you for your comment, but as this is almost a year old, I meanwhile solved the problem in a different way. To answer the question anyways: The XHTML page is encoded in UTF-8 using the xml encoding attribute plus <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>. Even when I entered text into the text field manually, its value was always platform-encoded.
– Alexander Reifinger
Sep 27 '12 at 12:19
1
…Then you should answer your own question so it is no longer marked 'unanswered'.
– rhavin
Jan 20 '14 at 14:15
Well, technically, it is unanswered - even though the answer no longer bothers (but interests) me. Anyway, if anyone answers with "This is intended behaviour" or "This cannot be reproduced" or "You are a moron", I will accept this as a valid answer :-)
– Alexander Reifinger
Jan 21 '14 at 16:09
add a comment |
This questions could use some clarification. What server side language are you using to read the database? How exactly are you encoding the webpage? Are you using "meta content="?
– mmcglynn
Sep 25 '12 at 14:25
1
Thank you for your comment, but as this is almost a year old, I meanwhile solved the problem in a different way. To answer the question anyways: The XHTML page is encoded in UTF-8 using the xml encoding attribute plus <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>. Even when I entered text into the text field manually, its value was always platform-encoded.
– Alexander Reifinger
Sep 27 '12 at 12:19
1
…Then you should answer your own question so it is no longer marked 'unanswered'.
– rhavin
Jan 20 '14 at 14:15
Well, technically, it is unanswered - even though the answer no longer bothers (but interests) me. Anyway, if anyone answers with "This is intended behaviour" or "This cannot be reproduced" or "You are a moron", I will accept this as a valid answer :-)
– Alexander Reifinger
Jan 21 '14 at 16:09
This questions could use some clarification. What server side language are you using to read the database? How exactly are you encoding the webpage? Are you using "meta content="?
– mmcglynn
Sep 25 '12 at 14:25
This questions could use some clarification. What server side language are you using to read the database? How exactly are you encoding the webpage? Are you using "meta content="?
– mmcglynn
Sep 25 '12 at 14:25
1
1
Thank you for your comment, but as this is almost a year old, I meanwhile solved the problem in a different way. To answer the question anyways: The XHTML page is encoded in UTF-8 using the xml encoding attribute plus <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>. Even when I entered text into the text field manually, its value was always platform-encoded.
– Alexander Reifinger
Sep 27 '12 at 12:19
Thank you for your comment, but as this is almost a year old, I meanwhile solved the problem in a different way. To answer the question anyways: The XHTML page is encoded in UTF-8 using the xml encoding attribute plus <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>. Even when I entered text into the text field manually, its value was always platform-encoded.
– Alexander Reifinger
Sep 27 '12 at 12:19
1
1
…Then you should answer your own question so it is no longer marked 'unanswered'.
– rhavin
Jan 20 '14 at 14:15
…Then you should answer your own question so it is no longer marked 'unanswered'.
– rhavin
Jan 20 '14 at 14:15
Well, technically, it is unanswered - even though the answer no longer bothers (but interests) me. Anyway, if anyone answers with "This is intended behaviour" or "This cannot be reproduced" or "You are a moron", I will accept this as a valid answer :-)
– Alexander Reifinger
Jan 21 '14 at 16:09
Well, technically, it is unanswered - even though the answer no longer bothers (but interests) me. Anyway, if anyone answers with "This is intended behaviour" or "This cannot be reproduced" or "You are a moron", I will accept this as a valid answer :-)
– Alexander Reifinger
Jan 21 '14 at 16:09
add a comment |
1 Answer
1
active
oldest
votes
Would the following be a solution for you?
function encode_utf8( s )
{
return unescape( encodeURIComponent( s ) );
}
where you call encode_utf8 with the value of your textbox? This is a suggestion from another SO answer found here. Not quite the same problem, but the solution might be applicable.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Would the following be a solution for you?
function encode_utf8( s )
{
return unescape( encodeURIComponent( s ) );
}
where you call encode_utf8 with the value of your textbox? This is a suggestion from another SO answer found here. Not quite the same problem, but the solution might be applicable.
add a comment |
Would the following be a solution for you?
function encode_utf8( s )
{
return unescape( encodeURIComponent( s ) );
}
where you call encode_utf8 with the value of your textbox? This is a suggestion from another SO answer found here. Not quite the same problem, but the solution might be applicable.
add a comment |
Would the following be a solution for you?
function encode_utf8( s )
{
return unescape( encodeURIComponent( s ) );
}
where you call encode_utf8 with the value of your textbox? This is a suggestion from another SO answer found here. Not quite the same problem, but the solution might be applicable.
Would the following be a solution for you?
function encode_utf8( s )
{
return unescape( encodeURIComponent( s ) );
}
where you call encode_utf8 with the value of your textbox? This is a suggestion from another SO answer found here. Not quite the same problem, but the solution might be applicable.
edited May 23 '17 at 12:16
Community♦
11
11
answered Feb 20 '14 at 18:08
KiranKiran
948714
948714
add a comment |
add a comment |
This questions could use some clarification. What server side language are you using to read the database? How exactly are you encoding the webpage? Are you using "meta content="?
– mmcglynn
Sep 25 '12 at 14:25
1
Thank you for your comment, but as this is almost a year old, I meanwhile solved the problem in a different way. To answer the question anyways: The XHTML page is encoded in UTF-8 using the xml encoding attribute plus <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>. Even when I entered text into the text field manually, its value was always platform-encoded.
– Alexander Reifinger
Sep 27 '12 at 12:19
1
…Then you should answer your own question so it is no longer marked 'unanswered'.
– rhavin
Jan 20 '14 at 14:15
Well, technically, it is unanswered - even though the answer no longer bothers (but interests) me. Anyway, if anyone answers with "This is intended behaviour" or "This cannot be reproduced" or "You are a moron", I will accept this as a valid answer :-)
– Alexander Reifinger
Jan 21 '14 at 16:09