Converts all XML reserved characters in the string to their safe entity codes for valid XML
| 881 | |
| 882 | /// Converts all XML reserved characters in the string to their safe entity codes for valid XML |
| 883 | std::string escape_xml_value(const std::string& value) { |
| 884 | std::string out; |
| 885 | out.reserve(value.size()); |
| 886 | |
| 887 | for (char c : value) { |
| 888 | switch (c) { |
| 889 | case '&': |
| 890 | out += "&"; |
| 891 | break; |
| 892 | case '<': |
| 893 | out += "<"; |
| 894 | break; |
| 895 | case '>': |
| 896 | out += ">"; |
| 897 | break; |
| 898 | default: |
| 899 | out += c; |
| 900 | break; |
| 901 | } |
| 902 | } |
| 903 | return out; |
| 904 | } |
| 905 | |
| 906 | /// Compresses a sorted set of indices into readable ranges such as '3-7, 10-12, 20'. |
| 907 | /// Consecutive values are grouped into ranges, whilst individual values are output separately. |