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:
2022-02-08 12:47:34 +01:00
parent 48d515ea64
commit 0bdabfc7b4
11 changed files with 252 additions and 274 deletions

View File

@@ -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
@@ -45,7 +45,6 @@ class PostgreSQLExpression : public DbExpression
{
public:
void esc(char val, pt::TextStream & stream, const FT & field_type);
void esc(const pt::Date & date, pt::TextStream & stream, const FT & field_type);
DbExpression & page(pt::TextStream & stream, size_t page_number, size_t page_size);
@@ -61,6 +60,7 @@ private:
void before_field_value_string(const FT & field_type);
void after_field_value_string(const FT & field_type);
bool esc_char(wchar_t val, pt::TextStream & stream);
};