By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

HTMLEncode works only in English chars, but not in other UTF-8 languages

P: n/a
Hi,

I have a textarea which the user can enter whatever text he chooses.

<TEXTAREA id=body name=body></TEXTAREA>

I would like to avoid supporting HTML tags in this textarea at the
moment, therefore I use the following HTML encode support:

Dim p_Body : p_Body = Server.HTMLEncode(Request.Form("Body"))

This works fine if I write text in latin characters (in English) - than
only the HTML tags are encoded.
But if I write text in other UTF-8 chars (e.g.: Hebrew) - all the text
is encoded, and it becomes unreadable.

What Am I doing wrong?

Thanks,
Gabi

Sep 17 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Gabriella wrote:
I have a textarea which the user can enter whatever text he chooses.

<TEXTAREA id=body name=body></TEXTAREA>

I would like to avoid supporting HTML tags in this textarea at the
moment, therefore I use the following HTML encode support:

Dim p_Body : p_Body = Server.HTMLEncode(Request.Form("Body"))

This works fine if I write text in latin characters (in English) -
than only the HTML tags are encoded.
But if I write text in other UTF-8 chars (e.g.: Hebrew) - all the text
is encoded, and it becomes unreadable.

What Am I doing wrong?
Might you be asking VBScript ASP questions in a javascript newsgroup?

What does the documentation for - Server.HTMLEncode - have to say on the
subject?

Richard.
Sep 17 '06 #2

P: n/a
You're right.
I thought there might be a simpler javascript solution for this
problem.

Gabi.

Richard Cornford wrote:
Gabriella wrote:
I have a textarea which the user can enter whatever text he chooses.

<TEXTAREA id=body name=body></TEXTAREA>

I would like to avoid supporting HTML tags in this textarea at the
moment, therefore I use the following HTML encode support:

Dim p_Body : p_Body = Server.HTMLEncode(Request.Form("Body"))

This works fine if I write text in latin characters (in English) -
than only the HTML tags are encoded.
But if I write text in other UTF-8 chars (e.g.: Hebrew) - all the text
is encoded, and it becomes unreadable.

What Am I doing wrong?

Might you be asking VBScript ASP questions in a javascript newsgroup?

What does the documentation for - Server.HTMLEncode - have to say on the
subject?

Richard.
Sep 17 '06 #3

P: n/a
VK

Gabriella wrote:
I thought there might be a simpler javascript solution for this
problem.
Well, a javascript solution means (aside of some browser-specific
ASP/JScript/runat cases) that all your problems are solved more-or-less
successfully before informing the Master (server) about the received
results. :-)

If this way is attractive enough for you - and if you can cope with a
*very small* yet *existing* amount of users with client-side scripting
disabled - then join the club, Sister :-)

What is the page encoding you are using? Any way to look at the actual
form you having problems with?

Sep 17 '06 #4

P: n/a

"Gabriella" <fr********@yahoo.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hi,

I have a textarea which the user can enter whatever text he chooses.

<TEXTAREA id=body name=body></TEXTAREA>

I would like to avoid supporting HTML tags in this textarea at the
moment, therefore I use the following HTML encode support:

Dim p_Body : p_Body = Server.HTMLEncode(Request.Form("Body"))

This works fine if I write text in latin characters (in English) - than
only the HTML tags are encoded.
But if I write text in other UTF-8 chars (e.g.: Hebrew) - all the text
is encoded, and it becomes unreadable.

What Am I doing wrong?

Thanks,
Gabi
It is an ASP question, but what the heck..
Be sure to set session.codepage to something like 65001 for UTF-8. I do this
in session_onstart.
You might want to write your own function to replace HTML-significant chars
in the textarea (just a series of replace() calls.)

---Bruce Wisentaner
Sep 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.