473,473 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Preserving the Character set inside text area

5 New Member
HI

I want to display the contents of a big XML inside a text area so that the user would be able to edit it. But the XML consists of characters such as & " which are interpreted by as & and " respectively.
But if this going to be the case the backend systems could not read them. I used <xmp>, but it is already deprecated and further it would not work inside text area. Could somebody help me with this.

in short : &amp; should be displayed as &amp; itself and not & inside the textarea.

Vinoth
Apr 4 '07 #1
16 4345
KevinADC
4,059 Recognized Expert Specialist
javascript I am sure can do the proper character escaping, but I don't know how to do it myself. You can also do it server side with PHP or perl or other scripting language. Bascially the & symbol needs to converted to &amp; so &amp; would become &amp;amp; etc etc etc.
Apr 4 '07 #2
AricC
1,892 Recognized Expert Top Contributor
HI

I want to display the contents of a big XML inside a text area so that the user would be able to edit it. But the XML consists of characters such as &amp; &quot; which are interpreted by as & and " respectively.
But if this going to be the case the backend systems could not read them. I used <xmp>, but it is already deprecated and further it would not work inside text area. Could somebody help me with this.

in short : &amp; should be displayed as &amp; itself and not & inside the textarea.

Vinoth
Maybe this is more of an XML question?
Apr 4 '07 #3
rite2vinoth
5 New Member
javascript I am sure can do the proper character escaping, but I don't know how to do it myself. You can also do it server side with PHP or perl or other scripting language. Bascially the & symbol needs to converted to &amp; so &amp; would become &amp;amp; etc etc etc.
Yeah.Basically the round about would be to do a replace all of &amp; with &amp;amp; and so on which we eventually did in the server side. But I wanted to know if anything could be done in the client side itself.

Thanks a lot anyways.
Apr 5 '07 #4
rite2vinoth
5 New Member
Maybe this is more of an XML question?
Not necessarily. The question is about the browser marking up the character sets and predominanty HTML stuff and javascript.

thanks
Apr 5 '07 #5
KevinADC
4,059 Recognized Expert Specialist
Yeah.Basically the round about would be to do a replace all of &amp; with &amp;amp; and so on which we eventually did in the server side. But I wanted to know if anything could be done in the client side itself.

Thanks a lot anyways.
I am pretty sure javascript can do the escaping, but I don't know how to do that or if in fact it can be done. Ask in the javascripting forum. As far as the browser itself goes, there is no mechanism I know of to do what you want.
Apr 5 '07 #6
rite2vinoth
5 New Member
I am pretty sure javascript can do the escaping, but I don't know how to do that or if in fact it can be done. Ask in the javascripting forum. As far as the browser itself goes, there is no mechanism I know of to do what you want.
Thanks Kevin for that. :-)
Apr 5 '07 #7
srinivasang87
2 New Member
I am pretty sure javascript can do the escaping, but I don't know how to do that or if in fact it can be done. Ask in the javascripting forum. As far as the browser itself goes, there is no mechanism I know of to do what you want.
I thought on the same lines. But javascript doesnt do anything special here!
These are the things I tried..

1. s=escape('&amp;');
document.writeln("escaped string : "+s);

t=unescape('&amp;');
document.writeln("unescaped string : "+t);

Both returned '&'

2. <xmp>&amp;</xmp> OR <pre>&amp;</pre>
Both were displayed AS IS (ALONG WITH TAGS) inside the text area. But <xmp> did work OUTSIDE the textarea. But not a great idea as its already deprecated!

3. <plaintext> -- NEVER use this! It will BREAK all the HTML code after the <PLAINTEXT> tag..... All the remaining HTML will be displayed AS IS to the user..
Apr 5 '07 #8
KevinADC
4,059 Recognized Expert Specialist
OK, but who said anything about using the <plaintext> tag?
Apr 5 '07 #9
drhowarddrfine
7,435 Recognized Expert Expert
<plaintext>? Are we making up elements as we go along?

You should carry on this javascript discussion on the javascript board.
Apr 5 '07 #10
KevinADC
4,059 Recognized Expert Specialist
<plaintext> is a legitimate html tag, or maybe I don't understand your comment.
Apr 6 '07 #11
drhowarddrfine
7,435 Recognized Expert Expert
No wonder I never heard of it. It was "obsoleted" in HTML 2.0 and listed as deprecated in 3.0 and 3.2. Only some browsers support it but IE and Firefox do not from what I read.
Apr 6 '07 #12
mrhoo
428 Contributor
I don't know if rite2 ever got an answer, but if you fetch any text file,
including xml,with an xhtmlHTTPRequest 'GET', and set the value of the textarea to the response text returned, the literal text will be displayed in the text area- &amps; <'s, and all.
Apr 6 '07 #13
KevinADC
4,059 Recognized Expert Specialist
No wonder I never heard of it. It was "obsoleted" in HTML 2.0 and listed as deprecated in 3.0 and 3.2. Only some browsers support it but IE and Firefox do not from what I read.

Deprecated is not the same as obsolete, although I believe I understand what you are saying. Even before the tag was deprecated it had no pratical use. I think it was mostly used by mischief makers with great results on unsuspecting html enabled forums, guestbooks, and such.

IE and FireFox do support it, but might not if the DTD is set properly.
Apr 6 '07 #14
AricC
1,892 Recognized Expert Top Contributor
We moving this to javascript? I believe the escape character in JS is \
Apr 6 '07 #15
rite2vinoth
5 New Member
We moving this to javascript? I believe the escape character in JS is \
Guys !! Thanks a ton for all of your suggestions. In fact we took the fool proof solution of going into the server side.

Mr.Moderator.How can i trace this thread in the JS forum ?

Vinoth
Apr 11 '07 #16
acoder
16,027 Recognized Expert Moderator MVP
Mr.Moderator.How can i trace this thread in the JS forum?
If you want to find your posts/threads, go to your Control Panel (top right-hand corner) and subscribed threads. Alternatively, go to your own user profile (if you can find one of your posts), then click on 'Find all posts by...'.
Apr 12 '07 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Cocy | last post by:
Hi, This might be a sort of FAQ, but I don't see why, so I would someone help me to understand what's wrong? I've just created following code which wold trim white space(s) in a (given) string....
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
2
by: Pete | last post by:
Hi all... I sincerly hope one of the MS guys can clear this up for me... First some background... Ok, I have a web site which is fully translatable into several languages. All the strings...
3
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
35
by: rajash | last post by:
Hello everyone, Thanks again for all the suggestions, though I think some people are a bit fussy in their answers. Here is a solution to Exercise 1.14. It deals well with control characters...
3
by: sophia.agnes | last post by:
Dear all, I was going through the book "C a software engineering approach by darnell & Margolis" there was a section named sign preserving vs value preserving it is as follows sign...
1
by: amulyab | last post by:
Hi, M using browse button to select a text file.The contents of text is made to display inside text area.Now i have to add some links for the some parts of text which is inside text area.How can i...
1
by: amulyab | last post by:
Hi, M using browse button to select a text file.The contents of text is made to display inside text area.Now i have to add some links for the some parts of text which is inside text area.How can i...
1
by: coolguyraj | last post by:
Hi i have the following HTML code for the text Area how can i disable the enter key inside the text area. <td colspan="7"><textarea cols="80" onkeypress="keyhandler<?php echo $x?>()" rows="5"...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.