| 42 | |
| 43 | template <typename CharT,typename Allocator=std::allocator<CharT>> |
| 44 | std::basic_string<CharT,std::char_traits<CharT>,Allocator> escape(jsoncons::basic_string_view<CharT> s, const Allocator& = Allocator()) |
| 45 | { |
| 46 | std::basic_string<CharT,std::char_traits<CharT>,Allocator> result; |
| 47 | |
| 48 | for (auto c : s) |
| 49 | { |
| 50 | if (JSONCONS_UNLIKELY(c == '~')) |
| 51 | { |
| 52 | result.push_back('~'); |
| 53 | result.push_back('0'); |
| 54 | } |
| 55 | else if (JSONCONS_UNLIKELY(c == '/')) |
| 56 | { |
| 57 | result.push_back('~'); |
| 58 | result.push_back('1'); |
| 59 | } |
| 60 | else |
| 61 | { |
| 62 | result.push_back(c); |
| 63 | } |
| 64 | } |
| 65 | return result; |
| 66 | } |
| 67 | |
| 68 | template <typename CharT> |
| 69 | std::basic_string<CharT> escape_string(const std::basic_string<CharT>& s) |