Project

General

Profile

Actions

Bug #793

closed
KR

Postgres backend doesn't set client encoding

Bug #793: Postgres backend doesn't set client encoding

Added by Kurt Roeckx over 15 years ago. Updated about 15 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
Start date:
04/18/2011
Due date:
% Done:

0%

Estimated time:

Description

Hi,

It seems that the postgres backend doesn't call PQsetClientEncoding(), and then probably assumes the client encoding is set to UTF-8. I at least get errors that widen() fails for strings that contain non-ASCII (latin1) characters. I assume they will go away when the proper client encoding is set.

Kurt

KD Updated by Koen Deforche over 15 years ago Actions #1

  • Status changed from New to Resolved

Hey,

Indeed, we are assuming UTF8. I've added a:

PQsetClientEncoding(conn_, "UTF8");

I couldn't find accurate documentation saying it would need to be "UTF8" or "UTF-8" but I do not get any warnings/errors from the database. So you might want to try if it fixes the issue for you ?

Regards,
koen

KR Updated by Kurt Roeckx over 15 years ago Actions #2

Koen Deforche wrote:

Hey,

Indeed, we are assuming UTF8. I've added a:
[...]

I couldn't find accurate documentation saying it would need to be "UTF8" or "UTF-8" but I do not get any warnings/errors from the database. So you might want to try if it fixes the issue for you ?

As far as I can see both are valid, but I think "UTF8" is the preferred way.

Anyway, the git repository hasn't changed the past 2 weeks.

Kurt

KR Updated by Kurt Roeckx over 15 years ago Actions #3

Koen Deforche wrote:

So you might want to try if it fixes the issue for you ?

So I just tried the current git snapshot. With the old version I got a "?" on the web page and a latin1 string in the error log, now I get "??" instead, and an utf-8 string in the log.

So the original problem I reported seems to be solved, but there is some other problem left.

Should I somehow set locale or something? That doesn't make sense to me, and so always setting it to UTF8 was wrong.
Or is there a call too much to toUTF8()?

Kurt

KR Updated by Kurt Roeckx over 15 years ago Actions #4

Kurt Roeckx wrote:

Koen Deforche wrote:
> So you might want to try if it fixes the issue for you ?

So I just tried the current git snapshot. With the old version I got a "?" on the web page and a latin1 string in the error log, now I get "??" instead, and an utf-8 string in the log.

So the original problem I reported seems to be solved, but there is some other problem left.

Should I somehow set locale or something? That doesn't make sense to me, and so always setting it to UTF8 was wrong.
Or is there a call too much to toUTF8()?

So I started using a Wt::WString instead std::string and that solved everything.

When converting a std::string to a Wt::WString I also always have to say it's an UTF8 string, else the conversion isn't working properly.

Kurt

KD Updated by Koen Deforche about 15 years ago Actions #5

  • Target version set to 3.1.10

KD Updated by Koen Deforche about 15 years ago Actions #6

  • Status changed from Resolved to Closed
Actions

Also available in: PDF Atom