Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Losing spaces when more than one space in text 1

Status
Not open for further replies.

marybailey

Programmer
Mar 14, 2002
47
US
I want the text entered in my form to retain its original spacing.


I have 2 textareas defined in an html form among other fields. They are defined as wrap=VIRTUAL tho wrap=hard and wrap= physical did not change the results.

I put the names and values of my form into an associative array.

My email textarea defined as follows in my html form:
<textarea name=&quot;emailsubject&quot; cols=&quot;40&quot; wrap=&quot;VIRTUAL&quot; rows=&quot;1&quot;></textarea><br>

My personalmsg textarea is defined as follows in my html form:
<textarea name=&quot;personalmsg&quot; cols=&quot;70&quot; wrap=&quot;virtual&quot; rows=&quot;10&quot;></textarea><br>


This is what I enter in the form:

for the emailsubject, I enter:
hi TESTING again

for the personalmsg, I enter:
hi
there.
testing
again.
* 1
* 2



Here is some code which does some formatting with the names and values of the fields.

# Un-Webify plus signs and %-encoding
$value =~ s/\+/ /g;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;

When I print out the personal msg value after this code it is reduced to one space.

hi
there.
testing
again.
* 1
* 2

Any ideas why?
 
Are you printing to a browser or a file? If you are printing to a browser and using a text/html header, then whitespace is ignored. Try either changing the header to text/plain just to test it or wrap the print in <pre></pre> tags.

If you are print to a file and having the problem then I'm stumped.

jaa
 
Thanks a million! I used the <PRE> tags.
What a relief.
Mrs B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top