mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-19 14:11:58 +00:00
49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#include <DB/IO/WriteBufferValidUTF8.h>
|
|
#include <DB/IO/WriteBufferFromString.h>
|
|
#include <DB/IO/ReadHelpers.h>
|
|
#include <DB/IO/WriteHelpers.h>
|
|
#include <string>
|
|
#include <streambuf>
|
|
#include <iostream>
|
|
#include <cstdio>
|
|
|
|
int main(int argc, char ** argv)
|
|
{
|
|
try
|
|
{
|
|
std::string test1 = "kjhsgdfkjhg2378rtzgvxkz877%^&^*%&^*&*";
|
|
std::string test2 = "{\"asd\" = \"qw1\",\"qwe24\" = \"3asd\"}";
|
|
test2[test2.find("1")] = 127 + 64;
|
|
test2[test2.find("2")] = 127 + 64 + 32;
|
|
test2[test2.find("3")] = 127 + 64 + 32 + 16;
|
|
test2[test2.find("4")] = 127 + 64 + 32 + 16 + 8;
|
|
|
|
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;
|
|
|
|
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;
|
|
}
|
|
|
|
return 0;
|
|
}
|