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

G

Gabriella

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
 
R

Richard Cornford

Gabriella said:
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.
 
G

Gabriella

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

Gabi.
 
V

VK

Gabriella said:
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?
 
B

Bruce Wisentaner

Gabriella said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top