fix: put 'char' type directly to the output stream
Char type was converted to wchar_t and then was serialized as utf-8 stream. Let char type will always be one char, of course it need to be a valid utf-8 sequence. Let FT::dont_use_utf8 apply only to wchar_t and std::wstring but ignore it if FT::hexadecimal or FT::binary are defined. Now we have bool BaseExpression::esc_char(wchar_t val, pt::TextStream & stream) method which (in most cases) will be used in derived classes. Let wchar_t (and std::wstring) will be stored as 8 hex digits when using FT::hexadecimal or FT::binary (and ignore FT::dont_use_utf8 in such a case).
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2018-2021, Tomasz Sowa
|
||||
* Copyright (c) 2018-2022, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -275,9 +275,11 @@ public:
|
||||
* esc for: signed char, wchar_t, char16_t, char32_t
|
||||
*
|
||||
*/
|
||||
virtual bool esc_char(char val, pt::TextStream & stream);
|
||||
virtual bool esc_char(wchar_t val, pt::TextStream & stream);
|
||||
|
||||
virtual void esc(char val, pt::TextStream & stream, const FT & field_type = FT::default_type);
|
||||
virtual void esc(unsigned char val, pt::TextStream & stream, const FT & field_type = FT::default_type);
|
||||
|
||||
virtual void esc(wchar_t val, pt::TextStream & stream, const FT & field_type = FT::default_type);
|
||||
|
||||
virtual void esc(const std::wstring & val, pt::TextStream & stream, const FT & field_type = FT::default_type);
|
||||
@@ -298,7 +300,6 @@ public:
|
||||
virtual void esc(float val, pt::TextStream & stream, const FT & field_type = FT::default_type);
|
||||
virtual void esc(double val, pt::TextStream & stream, const FT & field_type = FT::default_type);
|
||||
virtual void esc(long double val, pt::TextStream & stream, const FT & field_type = FT::default_type);
|
||||
//virtual void esc(void* val, pt::TextStream & stream);
|
||||
|
||||
virtual void esc(const pt::Date & date, pt::TextStream & stream, const FT & field_type = FT::default_type);
|
||||
virtual void esc(const pt::TextStream & val,pt::TextStream & stream, const FT & field_type = FT::default_type);
|
||||
@@ -628,8 +629,10 @@ protected:
|
||||
|
||||
char char_to_hex_part(char c);
|
||||
void char_to_hex(char c, pt::TextStream & stream);
|
||||
void char_to_hex(wchar_t c, pt::TextStream & stream);
|
||||
|
||||
void esc(const wchar_t * val, bool has_known_length, size_t len, pt::TextStream & stream, const FT & field_type = FT::default_type);
|
||||
void esc(const wchar_t * val, bool has_known_length, size_t len, pt::TextStream & stream, const FT & field_type);
|
||||
void esc(const char * val, bool has_known_length, size_t len, pt::TextStream & stream, const FT & field_type);
|
||||
|
||||
bool is_empty_field(const wchar_t * value);
|
||||
};
|
||||
|
Reference in New Issue
Block a user