* conversion between client encoding and server internal encoding
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
- * $Id: conv.c,v 1.3 1998/09/01 04:33:21 momjian Exp $
+ * $Id: conv.c,v 1.4 1998/12/14 04:59:58 momjian Exp $
*/
#include <stdio.h>
#include <string.h>
{
int c1;
- while (len > 0 && (c1 = *mic))
+ while (len-- > 0 && (c1 = *mic))
{
if (c1 > 0x7f)
printBogusChar(&mic, &p);
{ /* should be ASCII */
*p++ = c1;
}
+ mic++;
}
*p = '\0';
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.164 1998/11/17 14:26:31 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.165 1998/12/14 04:59:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#endif
+#ifdef MULTIBYTE
+/* flag to indicate if PGCLIENTENCODING has been set by a user */
+static int has_client_encoding;
+#endif
+
/* This prompt string is assumed to have at least 3 characters by code in MainLoop().
* A character two characters from the end is replaced each time by a mode character.
*/
/* FIXME: if changing user, ought to prompt for a new password? */
pwparam = PQpass(olddb);
+#ifdef MULTIBYTE
+ /* PGCLIENTENCODING may be set by the previous connection.
+ if a user does not explicitly set PGCLIENTENCODING,
+ we should discard PGCLIENTENCODING so that
+ libpq could get the backend encoding as the default
+ PGCLIENTENCODING value. -- 1998/12/12 Tatsuo Ishii */
+
+ if (!has_client_encoding) {
+ unsetenv("PGCLIENTENCODING");
+ }
+#endif
+
pset->db = PQsetdbLogin(PQhost(olddb), PQport(olddb),
NULL, NULL, dbparam, userparam, pwparam);
settings.getPassword = 0;
#endif
+#ifdef MUTIBYTE
+ has_client_encoding = getenv("PGCLIENTENCODING");
+#endif
+
while ((c = getopt(argc, argv, "Aa:c:d:ef:F:lh:Hnso:p:qStT:ux")) != EOF)
{
switch (c)