Carriage Returns and Newlines





When you press Enter on your computer, you are probably used to seeing the cursor move to the first position on the next line. Although this behavior requires only one keystroke, in reality, two things are happening: the cursor is moving down one line and then moving to the beginning of the line. Old typewriters required two actions for the same effect. You pressed the Return key, which shifted the paper up a line, and pushed the cylinder (or carriage) back to the left returning the carriage.
When you program CGI applications ' 'you should end each header line and the blank line separating the header and body with a CRLF (\r\n). For example, in order to print your de facto Content Type header in C, you would use
printf ("Content Type: text/html\r\n");
rather than
printf("Content Type: text/html\n");
Most servers remove anything at the end of the headers from the CGI progress add the proper CRLF combination themselves, so ending your headers. only a \n will normally work. However, there is no guarantee that all server, work in this manner, so you should make it a habit to use both V and \n a, end of each header line.
Domain Name Search
|