1 /*-------------------------------------------------------------------------
5 * Portions Copyright (c) 1996-2003, 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_euc_cn/utf8_and_euc_cn.c,v 1.6 2003/08/04 02:40:07 momjian Exp $
11 *-------------------------------------------------------------------------
16 #include "mb/pg_wchar.h"
17 #include "../../Unicode/euc_cn_to_utf8.map"
18 #include "../../Unicode/utf8_to_euc_cn.map"
20 PG_FUNCTION_INFO_V1(euc_cn_to_utf8);
21 PG_FUNCTION_INFO_V1(utf8_to_euc_cn);
23 extern Datum euc_cn_to_utf8(PG_FUNCTION_ARGS);
24 extern Datum utf8_to_euc_cn(PG_FUNCTION_ARGS);
28 * INTEGER, -- source encoding id
29 * INTEGER, -- destination encoding id
30 * CSTRING, -- source string (null terminated C string)
31 * CSTRING, -- destination string (null terminated C string)
32 * INTEGER -- source string length
37 euc_cn_to_utf8(PG_FUNCTION_ARGS)
39 unsigned char *src = PG_GETARG_CSTRING(2);
40 unsigned char *dest = PG_GETARG_CSTRING(3);
41 int len = PG_GETARG_INT32(4);
43 Assert(PG_GETARG_INT32(0) == PG_EUC_CN);
44 Assert(PG_GETARG_INT32(1) == PG_UTF8);
47 LocalToUtf(src, dest, LUmapEUC_CN,
48 sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
54 utf8_to_euc_cn(PG_FUNCTION_ARGS)
56 unsigned char *src = PG_GETARG_CSTRING(2);
57 unsigned char *dest = PG_GETARG_CSTRING(3);
58 int len = PG_GETARG_INT32(4);
60 Assert(PG_GETARG_INT32(0) == PG_UTF8);
61 Assert(PG_GETARG_INT32(1) == PG_EUC_CN);
64 UtfToLocal(src, dest, ULmapEUC_CN,
65 sizeof(ULmapEUC_CN) / sizeof(pg_utf_to_local), len);