| From: | Igor Korot <ikorot01(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: PQexecPrepared() question |
| Date: | 2025-12-22 23:07:52 |
| Message-ID: | CA+FnnTwz2PSSi2MVoH3rCKtAn=beRm97m7nGyxX1d3oF5EFVkw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi, Peter,
On Mon, Dec 22, 2025 at 1:55 AM Peter J. Holzer <hjp-pgsql(at)hjp(dot)at> wrote:
>
> On 2025-12-21 17:30:38 -0800, Igor Korot wrote:
> > On Sun, Dec 21, 2025 at 1:19 PM Peter J. Holzer <hjp-pgsql(at)hjp(dot)at> wrote:
> > > As I see it, Igor has two options:
> > >
> > > 1) Send UTF8. wcstombs is the wrong tool for this, since it uses the
> > > current locale which is obviously not using UTF-8. I don't program in
> > > C++, but I'm pretty sure there is a portable way to encode a string
> > > in UTF-8.
> [...]
> > > I think 1) is the better strategy, but them I've been a UTF-8 fan-boy
> > > for over 30 years ;-).
> >
> > Maybe all I need is something like this:
> >
> > convert(char *dest, const std::wstring src)
> > {
> > const wchar_t *temp = src.c_str();
> > while( *dest )
> > {
> > dest++;
> > }
> > while( *temp )
> > {
> > *dest = *temp;
> > dest++;
> > temp++;
> > }
> > *dest++ = '\0';
> > *dest = '\0';
> > }
> >
> > ?
>
> I hope your compiler complains loudly about that code. You can't just
> assign a wchar_t to a char and expect it to do anything sensible.
At least MSVC 2017 did not.
However, trying didn't solve it. Same error.
>
> A short search points to std::wstring_convert, but that has been
> deprecated in C++17, and it's not obvious to me what the replacement is.
>
> There is always ICU, of course, but that feels like cracking a nut with
> a sledgehammer.
I think ICU IS a replacement for wstring_comvert.
Will check it.
>
> Personally, I might roll my own if an hour of googling doesn't turn up
> anything promising (UTF-8 encoding is quite simple), but that shouldn't
> be necessary.
>
>
> hjp
>
> --
> _ | Peter J. Holzer | Story must make more sense than reality.
> |_|_) | |
> | | | hjp(at)hjp(dot)at | -- Charles Stross, "Creative writing
> __/ | http://www.hjp.at/ | challenge!"
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Igor Korot | 2025-12-23 22:08:20 | Case sensitivity |
| Previous Message | Peter J. Holzer | 2025-12-22 09:55:16 | Re: PQexecPrepared() question |