1 | #include <IO/WriteBufferValidUTF8.h> |
---|---|
2 | #include <IO/WriteBufferFromString.h> |
3 | #include <IO/ReadHelpers.h> |
4 | #include <IO/WriteHelpers.h> |
5 | #include <string> |
6 | #include <streambuf> |
7 | #include <iostream> |
8 | #include <cstdio> |
9 | |
10 | int main(int, char **) |
11 | { |
12 | try |
13 | { |
14 | std::string test1 = "kjhsgdfkjhg2378rtzgvxkz877%^&^*%&^*&*"; |
15 | std::string test2 = "{\"asd\" = \"qw1\",\"qwe24\" = \"3asd\"}"; |
16 | test2[test2.find('1')] = char(127 + 64); |
17 | test2[test2.find('2')] = char(127 + 64 + 32); |
18 | test2[test2.find('3')] = char(127 + 64 + 32 + 16); |
19 | test2[test2.find('4')] = char(127 + 64 + 32 + 16 + 8); |
20 | |
21 | std::string str; |
22 | { |
23 | DB::WriteBufferFromString str_buf(str); |
24 | { |
25 | DB::WriteBufferValidUTF8 utf_buf(str_buf, true, "-"); |
26 | DB::writeEscapedString(test1, utf_buf); |
27 | } |
28 | } |
29 | std::cout << str << std::endl; |
30 | |
31 | str = ""; |
32 | { |
33 | DB::WriteBufferFromString str_buf(str); |
34 | { |
35 | DB::WriteBufferValidUTF8 utf_buf(str_buf, true, "-"); |
36 | DB::writeEscapedString(test2, utf_buf); |
37 | } |
38 | } |
39 | std::cout << str << std::endl; |
40 | } |
41 | catch (const DB::Exception & e) |
42 | { |
43 | std::cerr << e.what() << ", "<< e.displayText() << std::endl; |
44 | return 1; |
45 | } |
46 | |
47 | return 0; |
48 | } |
49 |