473,320 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
4 1704
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
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
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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jonas Meurer | last post by:
hello, my script selects a comment saved as VARCHAR in MySQL and displays it inside an html page. the problem is, that the comment contains several special characters, as mysterious utf-8...
3
by: TeekUS | last post by:
hey ppl, i am currently developing a parsing application my input is a 10MB english text file the parsing works fine however every now and then a non english character appears that messes...
10
by: Danny | last post by:
In the classic asp, I can use escape built-in function (server side function) like this: <script language=javascript> var myContent = unescape(<%=escape(strContent)%>) </script> How do I do...
4
by: Andrea Williams | last post by:
I have a class that imports System.Web.UI.Page. The code below works: public string JScriptEncode(string strValue) { strValue = strValue.Replace(@"'", "\x27"); //' JScript encode...
4
by: Anders Both | last post by:
Hello dotnet.aspnet group - I want to do encode e.g. japanise or arabic text into something like: بةكوردي عةلي Before putting it in my HTML code (aspx page) . But when i try to use ...
3
by: Michael Gaillez | last post by:
Hi, I'm dynamically loading an assembly into an ASP.NET application. In the control that I load from that dynamic assembly I've tried to use Server.HTMLEncode but this results in a serious...
4
by: Andy Fish | last post by:
When using databinding, I have gotten into the habit of using single quotes (apostrophe) round attribute values rather than double quotes because this allows visual studio to work when there are...
2
by: Groove | last post by:
Hey guys. I'm working a large project that has dozens of forms to collect user input. A lot of the fields are text and capture long text from the user. It writes to MS SQL 2000. I've built a...
1
by: Alexander Higgins | last post by:
>>Thanks for the response.... Point Taken but this is not the case. Thus, if a person writes a text file on her or his computer and does not use UNICODE to save it, the current code page is...
1
by: clai83 | last post by:
(A) I am making a web application that needs to work in both an English/Japanese environment. This web application is intended to manage a company website (news releases, add new companies), and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.