1 /*-------------------------------------------------------------------------
5 * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
6 * Portions Copyright (c) 1994, Regents of the University of California
9 * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
11 *-------------------------------------------------------------------------
16 #include "mb/pg_wchar.h"
18 PG_FUNCTION_INFO_V1(ascii_to_utf8)
19 PG_FUNCTION_INFO_V1(utf8_to_ascii)
21 extern Datum ascii_to_utf8(PG_FUNCTION_ARGS);
22 extern Datum utf8_to_ascii(PG_FUNCTION_ARGS);
26 * INTEGER, -- source encoding id
27 * INTEGER, -- destination encoding id
28 * CSTRING, -- source string (null terminated C string)
29 * CSTRING, -- destination string (null terminated C string)
30 * INTEGER -- source string length
36 ascii_to_utf8(PG_FUNCTION_ARGS)
38 unsigned char *src = PG_GETARG_CSTRING(2);
39 unsigned char *dest = PG_GETARG_CSTRING(3);
40 int len = PG_GETARG_INT32(4);
42 Assert(PG_GETARG_INT32(0) == PG_SQL_ASCII);
43 Assert(PG_GETARG_INT32(1) == PG_UTF8);
46 pg_ascii2mic(src, dest, len);
52 utf8_to_ascii(PG_FUNCTION_ARGS)
54 unsigned char *src = PG_GETARG_CSTRING(2);
55 unsigned char *dest = PG_GETARG_CSTRING(3);
56 int len = PG_GETARG_INT32(4);
58 Assert(PG_GETARG_INT32(0) == PG_UTF8);
59 Assert(PG_GETARG_INT32(1) == PG_SQL_ASCII);
62 pg_mic2ascii(src, dest, len);