2017-04-01 09:19:00 +00:00
|
|
|
#include <IO/WriteBufferValidUTF8.h>
|
|
|
|
#include <IO/WriteBufferFromString.h>
|
|
|
|
#include <IO/ReadHelpers.h>
|
|
|
|
#include <IO/WriteHelpers.h>
|
2012-11-16 09:42:48 +00:00
|
|
|
#include <string>
|
|
|
|
#include <streambuf>
|
|
|
|
#include <iostream>
|
|
|
|
#include <cstdio>
|
|
|
|
|
2017-12-01 18:36:55 +00:00
|
|
|
int main(int, char **)
|
2012-11-16 09:42:48 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
try
|
|
|
|
{
|
2020-03-09 02:31:05 +00:00
|
|
|
std::string test1 = R"(kjhsgdfkjhg2378rtzgvxkz877%^&^*%&^*&*)";
|
|
|
|
std::string test2 = R"({"asd" = "qw1","qwe24" = "3asd"})";
|
2017-09-08 05:03:21 +00:00
|
|
|
test2[test2.find('1')] = char(127 + 64);
|
|
|
|
test2[test2.find('2')] = char(127 + 64 + 32);
|
|
|
|
test2[test2.find('3')] = char(127 + 64 + 32 + 16);
|
|
|
|
test2[test2.find('4')] = char(127 + 64 + 32 + 16 + 8);
|
2016-08-07 16:28:12 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
std::string str;
|
|
|
|
{
|
|
|
|
DB::WriteBufferFromString str_buf(str);
|
|
|
|
{
|
|
|
|
DB::WriteBufferValidUTF8 utf_buf(str_buf, true, "-");
|
|
|
|
DB::writeEscapedString(test1, utf_buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::cout << str << std::endl;
|
2016-08-07 16:28:12 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
str = "";
|
|
|
|
{
|
|
|
|
DB::WriteBufferFromString str_buf(str);
|
|
|
|
{
|
|
|
|
DB::WriteBufferValidUTF8 utf_buf(str_buf, true, "-");
|
|
|
|
DB::writeEscapedString(test2, utf_buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::cout << str << std::endl;
|
|
|
|
}
|
|
|
|
catch (const DB::Exception & e)
|
|
|
|
{
|
|
|
|
std::cerr << e.what() << ", " << e.displayText() << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
2016-08-07 16:28:12 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
return 0;
|
2012-11-16 09:42:48 +00:00
|
|
|
}
|