Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > HTMLEncode works only in English chars, but not in other UTF-8 languages

Reply
Thread Tools

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

 
 
Gabriella
Guest
Posts: n/a
 
      09-17-2006
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

 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      09-17-2006
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.


 
Reply With Quote
 
 
 
 
Gabriella
Guest
Posts: n/a
 
      09-17-2006
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.


 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      09-17-2006

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?

 
Reply With Quote
 
Bruce Wisentaner
Guest
Posts: n/a
 
      09-19-2006

"Gabriella" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Month, Day etc. names in other languages other than English Diego Ruby 2 08-16-2008 02:00 AM
Does Eclipse support languages other than English ? John Java 0 08-12-2007 01:06 AM
Latent semantic indexing, but for other languages than English ? Nuralanur@aol.com Ruby 0 03-12-2006 10:49 AM
UK Only - Courses in ESOL (English forSpeakers of Other Languages). M Computer Support 1 09-04-2005 11:01 AM
[py2exe.i18n] English works, German works, but not French. What do I miss? F. GEIGER Python 3 08-06-2004 10:01 AM



Advertisments