467,075 Members | 975 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,075 developers. It's quick & easy.

Showing all spaces without using the  

I am using ASP to read code from a text file that I am displaying on my
page. Because I do not want the code from the text file to be executed, I
used the Server.HTMLEncode() method to display it as it is in the file.
However, the spaces used to indent lines is still removed by the browser. I
cannot use VBScript's replace function to replace all spaces with  
because that would replace all spaces, including ones that I do not want
replaced as well as majorly increasing the size of my file. Is there any
way to display the spaces used to indent the lines without manually writing
a function to do it? Thank You.
--
Nathan Sokalski
nj********@hotmail.com
www.nathansokalski.com


Jul 19 '05 #1
  • viewed: 2914
Share:
6 Replies
On Thu, 1 Jul 2004 19:59:51 -0400, "Nathan Sokalski"
<nj********@hotmail.com> wrote:
I am using ASP to read code from a text file that I am displaying on my
page. Because I do not want the code from the text file to be executed, I
used the Server.HTMLEncode() method to display it as it is in the file.
However, the spaces used to indent lines is still removed by the browser. I
cannot use VBScript's replace function to replace all spaces with &nbsp;
because that would replace all spaces, including ones that I do not want
replaced as well as majorly increasing the size of my file. Is there any
way to display the spaces used to indent the lines without manually writing
a function to do it?


Yes. First, don't post to so many groups. This isn't DHTML or an ASP
component. It doesn't involve the HTML object model, and isn't
related to the SDK's. It's not even server side, so the ASP group is
also technically out. In fact, none of the groups you selected are
actually appropriate.

Look at the <pre></pre> tags in HTML. Google for a reference if you
don't understand them, or repost in a HTML group.

Jeff
Jul 19 '05 #2
Please only post to one newsgroup. You'll find that it makes life easier
for everyone.

Nathan Sokalski wrote:
I am using ASP to read code from a text file that I am displaying on my
page. Because I do not want the code from the text file to be executed, I
used the Server.HTMLEncode() method to display it as it is in the file.
However, the spaces used to indent lines is still removed by the browser. I
cannot use VBScript's replace function to replace all spaces with &nbsp;
because that would replace all spaces, including ones that I do not want
replaced as well as majorly increasing the size of my file. Is there any
way to display the spaces used to indent the lines without manually writing
a function to do it? Thank You.


Jul 19 '05 #3
What about making long lines wrap around? Some lines in code (such as HTML
tags with a lot of attributes) will be too long to fit on one line, but the
PRE tag prevents text wrap. Based on the website I usually use as a
reference, the width attribute (which sets the maximum characters in a line)
is deprecated, but it does not state what technology is used in it's place.
I can use it, but I prefer not to use deprecated attributes. Any ideas?

(I apologize for sending to multiple newsgroups. I tend to do that because
some groups are rarely used, I don't always know which group is the precise
one I want, and I don't want to subscribe to ALL newsgroups. I will do my
best to lessen this habit)
--
Nathan Sokalski
nj********@hotmail.com
www.nathansokalski.com

"Jeff Cochran" <je*********@zina.com> wrote in message
news:40****************@msnews.microsoft.com...
On Thu, 1 Jul 2004 19:59:51 -0400, "Nathan Sokalski"
<nj********@hotmail.com> wrote:
I am using ASP to read code from a text file that I am displaying on my
page. Because I do not want the code from the text file to be executed, I
used the Server.HTMLEncode() method to display it as it is in the file.
However, the spaces used to indent lines is still removed by the browser. Icannot use VBScript's replace function to replace all spaces with &nbsp;
because that would replace all spaces, including ones that I do not want
replaced as well as majorly increasing the size of my file. Is there any
way to display the spaces used to indent the lines without manually writinga function to do it?


Yes. First, don't post to so many groups. This isn't DHTML or an ASP
component. It doesn't involve the HTML object model, and isn't
related to the SDK's. It's not even server side, so the ASP group is
also technically out. In fact, none of the groups you selected are
actually appropriate.

Look at the <pre></pre> tags in HTML. Google for a reference if you
don't understand them, or repost in a HTML group.

Jeff

Jul 19 '05 #4
"Nathan Sokalski" wrote...
I am using ASP to read code from a text file that I am displaying on my
page. Because I do not want the code from the text file to be executed, I
used the Server.HTMLEncode() method to display it as it is in the file.
However, the spaces used to indent lines is still removed by the browser. I
cannot use VBScript's replace function to replace all spaces with &nbsp;
because that would replace all spaces, including ones that I do not want
replaced as well as majorly increasing the size of my file. Is there any
way to display the spaces used to indent the lines without manually writing
a function to do it? Thank You.


Use <pre> tag or, if the whole your page is just text,
assign "text/plain" mime type to it.

HTH

--
Alex Streletsky
Brainbench MVP for HTML
http://www.brainbench.com/
Jul 19 '05 #5
On Fri, 2 Jul 2004 02:28:12 -0400, "Nathan Sokalski"
<nj********@hotmail.com> wrote:
What about making long lines wrap around? Some lines in code (such as HTML
tags with a lot of attributes) will be too long to fit on one line, but the
PRE tag prevents text wrap. Based on the website I usually use as a
reference, the width attribute (which sets the maximum characters in a line)
is deprecated, but it does not state what technology is used in it's place.
I can use it, but I prefer not to use deprecated attributes. Any ideas?


Plenty. But again, it's not an ASP issue. It's a client-side display
issue. Try a client-side HTML group for solutions.

Jeff
Jul 19 '05 #6
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:#D**************@TK2MSFTNGP09.phx.gbl...
I am using ASP to read code from a text file that I am displaying on my
page. Because I do not want the code from the text file to be executed, I
used the Server.HTMLEncode() method to display it as it is in the file.
However, the spaces used to indent lines is still removed by the browser. I cannot use VBScript's replace function to replace all spaces with &nbsp;
because that would replace all spaces, including ones that I do not want
replaced as well as majorly increasing the size of my file. Is there any
way to display the spaces used to indent the lines without manually writing a function to do it? Thank You.
--
Nathan Sokalski
nj********@hotmail.com
www.nathansokalski.com

Write a function to only replace only the leading spaces of each line using
a regular expression.
Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Tjerk Wolterink | last post: by
12 posts views Thread by Robert Mark Bram | last post: by
5 posts views Thread by Naveen K Kohli | last post: by
2 posts views Thread by Rob T | last post: by
1 post views Thread by Vikram | last post: by
3 posts views Thread by yawnmoth | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.