mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-19 14:11:58 +00:00
d97b2edc7c
* Make separate libs Common/ZooKeeper and Common/ConfigProcessor renamed: dbms/src/Common/StringUtils.h -> dbms/src/Common/StringUtils/StringUtils.h * Fix space * Fix data in system.build_options * merge * merge
57 lines
1001 B
C++
57 lines
1001 B
C++
#include <Common/hex.h>
|
|
#include <Common/StringUtils/StringUtils.h>
|
|
#include <Common/escapeForFileName.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
std::string escapeForFileName(const std::string & s)
|
|
{
|
|
std::string res;
|
|
const char * pos = s.data();
|
|
const char * end = pos + s.size();
|
|
|
|
while (pos != end)
|
|
{
|
|
unsigned char c = *pos;
|
|
|
|
if (isWordCharASCII(c))
|
|
res += c;
|
|
else
|
|
{
|
|
res += '%';
|
|
res += hexDigitUppercase(c / 16);
|
|
res += hexDigitUppercase(c % 16);
|
|
}
|
|
|
|
++pos;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
std::string unescapeForFileName(const std::string & s)
|
|
{
|
|
std::string res;
|
|
const char * pos = s.data();
|
|
const char * end = pos + s.size();
|
|
|
|
while (pos != end)
|
|
{
|
|
if (!(*pos == '%' && pos + 2 < end))
|
|
{
|
|
res += *pos;
|
|
++pos;
|
|
}
|
|
else
|
|
{
|
|
++pos;
|
|
res += unhex2(pos);
|
|
pos += 2;
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
|
|
}
|