WIN1250 as server encoding

Started by Peter Eisentrautover 21 years ago4 messages
#1Peter Eisentraut
peter_e@gmx.net
1 attachment(s)

Some people have requested to add WIN1250 as an allowed server encoding.
So far, the order of the encoding numbers determined which ones were
client-only, so in order not to renumber the encodings, I could only
come up with the attached ugly solution. If no one thinks of a better
one, we'll go with that.

It would also be good if someone who has an environment that calls for
WIN1250 (that is, Windows and an appropriate language environment)
could test whether this actually does anything besides compiling
without errors. :)

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Attachments:

win1250.difftext/x-diff; charset=us-ascii; name=win1250.diffDownload
diff -cr ../cvs-pgsql/src/include/mb/pg_wchar.h ./src/include/mb/pg_wchar.h
*** ../cvs-pgsql/src/include/mb/pg_wchar.h	2004-09-11 00:10:58.000000000 +0200
--- ./src/include/mb/pg_wchar.h	2004-09-15 16:51:40.000000000 +0200
***************
*** 143,149 ****
   *			in the pg_enc2name[] (mb/encnames.c) array!
   *
   *			If you add some encoding don'y forget check
!  *			PG_ENCODING_[BE|FE]_LAST macros.
   *
   *		The PG_SQL_ASCII is default encoding and must be = 0.
   */
--- 143,149 ----
   *			in the pg_enc2name[] (mb/encnames.c) array!
   *
   *			If you add some encoding don'y forget check
!  *			PG_VALID_[BE|FE]_ENCODING macros.
   *
   *		The PG_SQL_ASCII is default encoding and must be = 0.
   */
***************
*** 177,210 ****
  	PG_ISO_8859_6,				/* ISO-8859-6 */
  	PG_ISO_8859_7,				/* ISO-8859-7 */
  	PG_ISO_8859_8,				/* ISO-8859-8 */
! 
! 	/* followings are for client encoding only */
! 	PG_SJIS,					/* Shift JIS (Winindows-932) */
! 	PG_BIG5,					/* Big5 (Windows-950) */
! 	PG_GBK,						/* GBK (Windows-936) */
! 	PG_UHC,						/* UHC (Windows-949) */
  	PG_WIN1250,					/* windows-1250 */
! 	PG_GB18030,					/* GB18030 */
  	_PG_LAST_ENCODING_			/* mark only */
  
  } pg_enc;
  
- #define PG_ENCODING_BE_LAST PG_ISO_8859_8
- #define PG_ENCODING_FE_LAST PG_GB18030
  
  /*
   * Please use these tests before access to pg_encconv_tbl[]
   * or to other places...
   */
- #define PG_VALID_BE_ENCODING(_enc) \
- 		((_enc) >= 0 && (_enc) <= PG_ENCODING_BE_LAST)
- 
- #define PG_ENCODING_IS_CLIEN_ONLY(_enc) \
- 		(((_enc) > PG_ENCODING_BE_LAST && (_enc) <= PG_ENCODING_FE_LAST)
- 
  #define PG_VALID_ENCODING(_enc) \
  		((_enc) >= 0 && (_enc) < _PG_LAST_ENCODING_)
  
  /* On FE are possible all encodings
   */
  #define PG_VALID_FE_ENCODING(_enc)	PG_VALID_ENCODING(_enc)
--- 177,211 ----
  	PG_ISO_8859_6,				/* ISO-8859-6 */
  	PG_ISO_8859_7,				/* ISO-8859-7 */
  	PG_ISO_8859_8,				/* ISO-8859-8 */
! 	PG_SJIS,					/* Shift JIS (Winindows-932), client only */
! 	PG_BIG5,					/* Big5 (Windows-950), client only */
! 	PG_GBK,						/* GBK (Windows-936), client only */
! 	PG_UHC,						/* UHC (Windows-949), client only */
  	PG_WIN1250,					/* windows-1250 */
! 	PG_GB18030,					/* GB18030, client only */
  	_PG_LAST_ENCODING_			/* mark only */
  
  } pg_enc;
  
  
  /*
   * Please use these tests before access to pg_encconv_tbl[]
   * or to other places...
   */
  #define PG_VALID_ENCODING(_enc) \
  		((_enc) >= 0 && (_enc) < _PG_LAST_ENCODING_)
  
+ #define PG_ENCODING_IS_CLIENT_ONLY(_enc) \
+ 		(PG_VALID_ENCODING(_enc) \
+ 		 && (((_enc) == PG_SJIS) \
+ 			 || ((_enc) == PG_BIG5) \
+ 			 || ((_enc) == PG_GBK) \
+ 			 || ((_enc) == PG_UHC) \
+ 			 || ((_enc) == PG_GB18030)))
+ 
+ #define PG_VALID_BE_ENCODING(_enc) \
+ 		(PG_VALID_ENCODING(_enc) && !PG_ENCODING_IS_CLIENT_ONLY(_enc))
+ 
  /* On FE are possible all encodings
   */
  #define PG_VALID_FE_ENCODING(_enc)	PG_VALID_ENCODING(_enc)
Nur in ./src: Makefile.custom.
In reply to: Peter Eisentraut (#1)
Re: WIN1250 as server encoding

On Wed, Sep 15, 2004 at 05:02:44PM +0200, Peter Eisentraut wrote:

Some people have requested to add WIN1250 as an allowed server encoding.
So far, the order of the encoding numbers determined which ones were
client-only, so in order not to renumber the encodings, I could only
come up with the attached ugly solution. If no one thinks of a better
one, we'll go with that.

Probably a silly suggestion, but... A second encoding number which happens
to assign the same character codes as WIN1250, with a 1-to-1 translation
table, and renaming the old number to make room for the new one in newly
compiled code?

Jeroen

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#1)
Re: WIN1250 as server encoding

Peter Eisentraut <peter_e@gmx.net> writes:

Some people have requested to add WIN1250 as an allowed server encoding.
So far, the order of the encoding numbers determined which ones were
client-only, so in order not to renumber the encodings, I could only
come up with the attached ugly solution. If no one thinks of a better
one, we'll go with that.

Can't we just renumber them?

AFAIR, the only place where these numbers are stored is in
pg_database.datencoding, so only the server-encoding values are frozen
in any meaningful sense. You could rearrange the numbers currently
assigned to client encodings to preserve the range property.

regards, tom lane

#4Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#3)
Re: WIN1250 as server encoding

Tom Lane wrote:

AFAIR, the only place where these numbers are stored is in
pg_database.datencoding, so only the server-encoding values are
frozen in any meaningful sense. You could rearrange the numbers
currently assigned to client encodings to preserve the range
property.

Interesting. I guess I was too traumatized by the last numbering change
to ignore that possibility. Does anyone else see a problem with that?

--
Peter Eisentraut
http://developer.postgresql.org/~petere/