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

Discussion in 'Javascript' started by Gabriella, Sep 17, 2006.

  1. Gabriella

    Gabriella Guest

    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
     
    Gabriella, Sep 17, 2006
    #1
    1. Advertising

  2. 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.
     
    Richard Cornford, Sep 17, 2006
    #2
    1. Advertising

  3. Gabriella

    Gabriella Guest

    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.
     
    Gabriella, Sep 17, 2006
    #3
  4. Gabriella

    VK Guest

    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?
     
    VK, Sep 17, 2006
    #4
  5. "Gabriella" <> wrote in message
    news:...
    > 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
     
    Bruce Wisentaner, Sep 19, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F. GEIGER
    Replies:
    3
    Views:
    776
    F. GEIGER
    Aug 6, 2004
  2. John
    Replies:
    0
    Views:
    323
  3. Hongyu
    Replies:
    9
    Views:
    913
    James Kanze
    Aug 8, 2008
  4. Replies:
    0
    Views:
    131
  5. Diego
    Replies:
    2
    Views:
    151
    Stefan Rusterholz
    Aug 16, 2008
Loading...

Share This Page