Question
In C++ HTML Encode Write a program that reads from stdin, prints to stdout, and encodes characters that have special meaning in an HTML file.
In C++
HTML Encode
Write a program that reads from stdin, prints to stdout, and encodes characters that have special meaning in an HTML file.
If a character in an input stream is one of the following five special characters, then it must be converted to an HTML-named entity as described in the following table.
Character HTML-encoding
& &
< <
> >
"
' '
For example, the following input stream:
This is a test file. All the special html characters should be escaped by the htmlencode application! These include the less-than, greater-than, quotes, and the ampersand: &<>"'
Another example: A more complex example... &&<<>>'''""" <&&'>&;"> < > > ' " & / +
File you must submit: htmlencode.cc
Hints: In order to read every character from std::cin without the spaces removed, you can prevent C++ from removing them by adding this line at the beginning of your program. std::cin >> std::noskipws;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started