html.hpp 464 B

12345678910111213141516171819
  1. #pragma once
  2. namespace nall::Encode {
  3. inline auto HTML(const string& input) -> string {
  4. string output;
  5. for(char c : input) {
  6. if(c == '&' ) { output.append("&" ); continue; }
  7. if(c == '<' ) { output.append("&lt;" ); continue; }
  8. if(c == '>' ) { output.append("&gt;" ); continue; }
  9. if(c == '"' ) { output.append("&quot;"); continue; }
  10. if(c == '\'') { output.append("&apos;"); continue; }
  11. output.append(c);
  12. }
  13. return output;
  14. }
  15. }