Re: Database->ServerEncoding, ClientEncoding - Mailing list pgadmin-hackers

From Jean-Michel POURE
Subject Re: Database->ServerEncoding, ClientEncoding
Date
Msg-id 200202252107.g1PL7ILx005532@www1.translationforge
Whole thread Raw
In response to Re: Database->ServerEncoding, ClientEncoding  ("Dave Page" <dpage@vale-housing.co.uk>)
List 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?

pgadmin-hackers by date:

Previous
From: "Dave Page"
Date:
Subject: Re: Database->ServerEncoding, ClientEncoding (again)
Next
From: Hiroshi Inoue
Date:
Subject: Re: pgAdmin2 Japanese display