improve escaping characters from multibyte strings
Read the whole character from a multibyte string and then escape it. while here: - add more virtual methods for escaping strings to BaseExpression
This commit is contained in:
@@ -568,53 +568,95 @@ void BaseExpression::esc(char32_t val, pt::Stream & stream, const FT & field_typ
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const wchar_t * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
void BaseExpression::esc_numeric_string(const char * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( field_type.is_numeric() )
|
||||
{
|
||||
esc_numeric_string(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
else
|
||||
{
|
||||
esc_normal_string(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
esc_numeric_string_generic(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const char * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
void BaseExpression::esc_numeric_string(const wchar_t * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( field_type.is_numeric() )
|
||||
{
|
||||
esc_numeric_string(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
else
|
||||
{
|
||||
esc_normal_string(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
esc_numeric_string_generic(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc_hex_string(const char * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
esc_hex_string_generic(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc_hex_string(const wchar_t * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
esc_hex_string_generic(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc_bin_string(const char * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
esc_hex_string(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc_bin_string(const wchar_t * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
esc_hex_string(val, has_known_length, len, stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc_ordinary_string(const char * val, size_t val_len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
pt::utf8_to_output_function(val, val_len, [&](int c){
|
||||
esc(static_cast<char32_t>(c), stream, field_type, model_env);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc_ordinary_string(const char * val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
pt::utf8_to_output_function(val, [&](int c){
|
||||
esc(static_cast<char32_t>(c), stream, field_type, model_env);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc_ordinary_string(const wchar_t * val, size_t val_len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
pt::wide_to_output_function(val, val_len, [&](int c){
|
||||
esc(static_cast<char32_t>(c), stream, field_type, model_env);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc_ordinary_string(const wchar_t * val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
pt::wide_to_output_function(val, [&](int c){
|
||||
esc(static_cast<char32_t>(c), stream, field_type, model_env);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const std::wstring & val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
esc(val.c_str(), true, val.size(), stream, field_type, model_env);
|
||||
esc_string(val.c_str(), true, val.size(), stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const wchar_t * val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
esc(val, false, 0, stream, field_type, model_env);
|
||||
esc_string(val, false, 0, stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const std::string & val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
esc(val.c_str(), true, val.size(), stream, field_type, model_env);
|
||||
esc_string(val.c_str(), true, val.size(), stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const char * val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
esc(val, false, 0, stream, field_type, model_env);
|
||||
esc_string(val, false, 0, stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user