use a char32_t character as a main character when converting strings
Use a char32_t instead of a wchar_t type. This is needed on systems where sizeof(wchar_t) is equal to 2.
This commit is contained in:
@@ -467,7 +467,7 @@ void BaseExpression::char_to_hex(char c, pt::Stream & stream)
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::char_to_hex(wchar_t c, pt::Stream & stream)
|
||||
void BaseExpression::char_to_hex(char32_t c, pt::Stream & stream)
|
||||
{
|
||||
unsigned int z = static_cast<unsigned int>(c);
|
||||
|
||||
@@ -485,17 +485,28 @@ void BaseExpression::char_to_hex(wchar_t c, pt::Stream & stream)
|
||||
*/
|
||||
bool BaseExpression::esc_char(char val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
return esc_char((wchar_t)(unsigned char)val, stream, field_type, model_env);
|
||||
return esc_char((char32_t)(unsigned char)val, stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* return true if the val character was escaped and put (or ignored) to the stream
|
||||
*
|
||||
* in most cases you have to provide your own esc_char(wchar_t val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env) method
|
||||
*
|
||||
*/
|
||||
bool BaseExpression::esc_char(wchar_t val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
return esc_char((char32_t)val, stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* return true if the val character was escaped and put (or ignored) to the stream
|
||||
*
|
||||
* in most cases you have to provide your own esc_char(char32_t val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env) method
|
||||
*
|
||||
*/
|
||||
bool BaseExpression::esc_char(char32_t val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -524,6 +535,12 @@ void BaseExpression::esc(unsigned char val, pt::Stream & stream, const FT & fiel
|
||||
|
||||
|
||||
void BaseExpression::esc(wchar_t val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
esc(static_cast<char32_t>(val), stream, field_type, model_env);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(char32_t val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( field_type.is_binary() || field_type.is_hexadecimal() )
|
||||
{
|
||||
@@ -720,18 +737,17 @@ void BaseExpression::esc(const pt::Stream & val, pt::Stream & stream, const FT &
|
||||
if( val.is_char_stream() )
|
||||
{
|
||||
// from utf8 to utf8 or from utf8 to wide
|
||||
pt::utf8_to_output_function(val, [&](int z) {
|
||||
esc(static_cast<wchar_t>(z), stream, field_type, model_env);
|
||||
pt::utf8_to_output_function_by_index(val, [&](int z) {
|
||||
esc(static_cast<char32_t>(z), stream, field_type, model_env);
|
||||
});
|
||||
}
|
||||
else
|
||||
if( val.is_wchar_stream() )
|
||||
{
|
||||
// from wide to wide or from wide to utf8
|
||||
for(size_t i=0 ; i < val.size() ; ++i)
|
||||
{
|
||||
esc(val.get_wchar(i), stream, field_type, model_env);
|
||||
}
|
||||
pt::wide_to_output_function_by_index(val, [&](int z) {
|
||||
esc(static_cast<char32_t>(z), stream, field_type, model_env);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user