Re: Database->ServerEncoding, ClientEncoding

From: Jean-Michel POURE <jm(dot)poure(at)freesurf(dot)fr>
To: "Dave Page" <dpage(at)vale-housing(dot)co(dot)uk>
Cc: <pgadmin-hackers(at)postgresql(dot)org>
Subject: Re: Database->ServerEncoding, ClientEncoding
Date: 2002-02-25 21:07:18
Message-ID: 200202252107.g1PL7ILx005532@www1.translationforge
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Hi Dave,

1) We need two client encodings :
- one for querying system object,
- another for displaying data.

> DataEncodingID (Long)
> DataEncodingName (String)
The encoding used to display data.
In my example, UTF-8 to export data, Latin1 otherwize.

> SystemEncodingID (Long)
> SystemEncodingName (String)
The encoding used to program schema objects, in my case Latin1.
"System" because this term is used in pgServerExecSQL.

Example : my database is UTF-8:
- Latin1 objects,
- Japanese data.

2) I hacked pgServerExecSQL like this :
>As I said in my previous message, we can only set it once for each
database, otherwise it will become unpredictable as you jump from window
to window.

'Get the Query Type and set client encoding
szClientEncoding = "SQL_ASCII"
SQL_Encoding = ""

If (QryType And qrySystem) = qrySystem Then
szQueryType = "System"
szClientEncoding = objServer.Databases(Database).SystemEncodingName
ElseIf (QryType And qryData) = qryData Then
szQueryType = "Data"
szClientEncoding = objServer.Databases(Database).DataEncodingName
ElseIf (QryType And qryUser) = qryUser Then
szQueryType = "User"
szClientEncoding = "SQL_ASCII"
End If

If szClientEncoding <> "" Then
SQL_Encoding = "SET CLIENT_ENCODING = '" & szClientEncoding & "'; "
End If

RaiseEvent SQLExecute(SQL, Connection)
objServer.iLogEvent "SQL (" & GetDatabase(Connection.ConnectionString) &
"): " & SQL, etSQL
Set ExecSQL = Connection.Execute(SQL_Encoding & SQL)

What do you think?

In response to

Browse pgadmin-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 2002-02-26 05:24:23 Re: pgAdmin2 Japanese display
Previous Message Dave Page 2002-02-25 20:30:28 Re: Database->ServerEncoding, ClientEncoding (again)