Forum Moderators: open
Please help me understand the following situation and perhaps if you can help me fix it. I’m working on a web page to allow users enter c++ code segments. Because of the requirements of my application I cannot fit everything on one page so I have written a JavaScript to open a second window with a textarea element where the actual c++ code is entered. Things work fine until I try to open a previously entered code segment with special characters like apostrophe or left shift using Netscape 6.1. So something like the following will open in the textarea of the second window when using IE 6 but not when using Netscape 6.1:
<code snippet 1>
float f;
int *p = (int*)&f;
<code snippet 2>
printf("%02x%c", *p++, len? '' : '\n');
What can I do? I really need to open the second window through JavaScript as I'm doing now for a cohesive flow of the application. Could someone please suggest a way out of this Netscape dilemma? I tried replacing apostrophe and the other special characters with their escape sequences, but that didn't work either. In fact in the case of left shift < worked whereas its escape sequence < didn't.
Thanks in advance for your help and advice
Are you saying that standard Ascii Characters are not displaying in a NN6.1 textarea? Give us a few special Chars that don't output and we'll try to suss what the problem is.
Or are you saying the entire textarea isn't displaying? If the later look at this thread-http://www.webmasterworld.com/forum21/4629.htm
The thread you’re referring to was posted by me and it was a different problem. I was able to solve that problem by following the solution you suggested. This problem is different and it’s about displaying special characters in the textarea of the second window. When I open a new window through JavaScript window.open() I am able to successfully initialize the textarea element of the new window but only if there is no apostrophe in the initializing text. The following text:
<code snippet 1>
float f;
int *p = (int*)&f;
<code snippet 2>
printf("%02x%c", *p++, len? '' : '\n');
Will not show correctly in the textarea of the window when using NN6.1 The first problem is that in the text above if I replace the first < with it’s escape sequence < the entire text disappears because everything falls after <.
If however, I keep < the text will be displayed only up to printf("%02x%c", *p++, len?
The apostrophe and everything after get chopped off.
I hope that I’ve been more clear.
Thanks for your help
#!/usr/bin/perl
# get input if any
&get_data;
&output;
sub get_data {
local($name, $value, $pair, $buffer, @pairs);
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ s/\n//g;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\n//g;
$value =~ s/<!--(.¦\n)*-->//g;
$FORM{$name} = $value;
}
return(1);
}
sub output {
print "Content-type: text/html\n\n";
print qq¦ <HTML><FORM name=screen>
<Textarea rows=10 cols=40 name=output>
$FORM{'$name_of_input'}
</Textarea>
</form>
</html> ¦;
}
Untested ^, and I'm not very good at Perl.
You may need to change the path to perl.
I think the problem you are describing stems from you are using Javascript to initialise the textarea output without unescaping the quote marks.
string ="printf("%02x%c", *p++, len? '' : '\n');" will produce a javascript error
string ="printf(\"%02x%c\", *p++, len? '' : '\n');" is ok
I think you'll need to escape the characters, ie
" should be mapped to \"
newline should be mapped to \n
Best get some work done
-Mark