diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-04-25 21:50:58 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-04-25 21:50:58 +0000 |
| commit | 122923c97febe794796ede5c9a35d6c317bcde30 (patch) | |
| tree | a7b586966c51d78bea013d416472ff7d18011d33 /src/backend/libpq/pqformat.c | |
| parent | 0d99c95388a7edc4ddb8897776e80de00944ded0 (diff) | |
| download | postgresql-122923c97febe794796ede5c9a35d6c317bcde30.tar.gz | |
Still had a few MULTIBYTE problems when client encoding was
different from database's ...
Diffstat (limited to 'src/backend/libpq/pqformat.c')
| -rw-r--r-- | src/backend/libpq/pqformat.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/backend/libpq/pqformat.c b/src/backend/libpq/pqformat.c index ad6f045a94..45b4259d8b 100644 --- a/src/backend/libpq/pqformat.c +++ b/src/backend/libpq/pqformat.c @@ -15,13 +15,13 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pqformat.c,v 1.2 1999/04/25 19:27:44 tgl Exp $ + * $Id: pqformat.c,v 1.3 1999/04/25 21:50:56 tgl Exp $ * *------------------------------------------------------------------------- */ /* * INTERFACE ROUTINES - * Message output: + * Message assembly and output: * pq_beginmessage - initialize StringInfo buffer * pq_sendbyte - append a raw byte to a StringInfo buffer * pq_sendint - append a binary integer to a StringInfo buffer @@ -33,6 +33,9 @@ * the regular StringInfo routines, but this is discouraged since required * MULTIBYTE conversion may not occur. * + * Special-case message output: + * pq_puttextmessage - generate a MULTIBYTE-converted message in one step + * * Message input: * pq_getint - get an integer from connection * pq_getstr - get a null terminated string from connection @@ -210,6 +213,32 @@ pq_endmessage(StringInfo buf) } /* -------------------------------- + * pq_puttextmessage - generate a MULTIBYTE-converted message in one step + * + * This is the same as the pqcomm.c routine pq_putmessage, except that + * the message body is a null-terminated string to which MULTIBYTE + * conversion applies. + * + * returns 0 if OK, EOF if trouble + * -------------------------------- + */ +int +pq_puttextmessage(char msgtype, const char *str) +{ + int slen = strlen(str); +#ifdef MULTIBYTE + const char *p; + p = (const char *) pg_server_to_client((unsigned char *) str, slen); + if (p != str) /* actual conversion has been done? */ + { + str = p; + slen = strlen(str); + } +#endif + return pq_putmessage(msgtype, str, slen+1); +} + +/* -------------------------------- * pq_getint - get an integer from connection * * returns 0 if OK, EOF if trouble |
