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:
@@ -332,10 +332,12 @@ public:
|
||||
*/
|
||||
virtual bool esc_char(char val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr);
|
||||
virtual bool esc_char(wchar_t val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr);
|
||||
virtual bool esc_char(char32_t val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr);
|
||||
|
||||
virtual void esc(char val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr);
|
||||
virtual void esc(unsigned char val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr);
|
||||
virtual void esc(wchar_t val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr);
|
||||
virtual void esc(char32_t val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr);
|
||||
|
||||
virtual void esc(const std::wstring & val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr);
|
||||
virtual void esc(const wchar_t * val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr);
|
||||
@@ -366,24 +368,17 @@ public:
|
||||
if( val.is_char_stream() )
|
||||
{
|
||||
// from utf8 to utf8 or from utf8 to wide
|
||||
typename pt::TextStreamBase<char_type, stack_size, heap_block_size>::const_iterator start = val.begin();
|
||||
typename pt::TextStreamBase<char_type, stack_size, heap_block_size>::const_iterator end = val.end();
|
||||
|
||||
pt::utf8_to_output_function(start, end, [&](int z) {
|
||||
esc(static_cast<wchar_t>(z), stream, field_type, model_env);
|
||||
pt::utf8_to_output_function(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
|
||||
typename pt::TextStreamBase<char_type, stack_size, heap_block_size>::const_iterator i = val.begin();
|
||||
typename pt::TextStreamBase<char_type, stack_size, heap_block_size>::const_iterator end = val.end();
|
||||
|
||||
for(; i != end ; ++i)
|
||||
{
|
||||
esc(*i, stream, field_type, model_env);
|
||||
}
|
||||
pt::wide_to_output_function(val, [&](int z) {
|
||||
esc(static_cast<char32_t>(z), stream, field_type, model_env);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -762,7 +757,7 @@ protected:
|
||||
|
||||
char char_to_hex_part(char c);
|
||||
void char_to_hex(char c, pt::Stream & stream);
|
||||
void char_to_hex(wchar_t c, pt::Stream & stream);
|
||||
void char_to_hex(char32_t c, pt::Stream & stream);
|
||||
|
||||
void esc(const wchar_t * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
void esc(const char * val, bool has_known_length, size_t len, pt::Stream & stream, const FT & field_type, ModelEnv * model_env);
|
||||
|
Reference in New Issue
Block a user