1 /*-------------------------------------------------------------------------
5 * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
6 * Portions Copyright (c) 1994, Regents of the University of California
9 * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.18 2007/11/15 21:14:40 momjian Exp $
11 *-------------------------------------------------------------------------
16 #include "mb/pg_wchar.h"
17 #include "../../Unicode/euc_kr_to_utf8.map"
18 #include "../../Unicode/utf8_to_euc_kr.map"
22 PG_FUNCTION_INFO_V1(euc_kr_to_utf8);
23 PG_FUNCTION_INFO_V1(utf8_to_euc_kr);
25 extern Datum euc_kr_to_utf8(PG_FUNCTION_ARGS);
26 extern Datum utf8_to_euc_kr(PG_FUNCTION_ARGS);
30 * INTEGER, -- source encoding id
31 * INTEGER, -- destination encoding id
32 * CSTRING, -- source string (null terminated C string)
33 * CSTRING, -- destination string (null terminated C string)
34 * INTEGER -- source string length
39 euc_kr_to_utf8(PG_FUNCTION_ARGS)
41 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
42 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
43 int len = PG_GETARG_INT32(4);
45 Assert(PG_GETARG_INT32(0) == PG_EUC_KR);
46 Assert(PG_GETARG_INT32(1) == PG_UTF8);
49 LocalToUtf(src, dest, LUmapEUC_KR, NULL,
50 sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), 0, PG_EUC_KR, len);
56 utf8_to_euc_kr(PG_FUNCTION_ARGS)
58 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
59 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
60 int len = PG_GETARG_INT32(4);
62 Assert(PG_GETARG_INT32(0) == PG_UTF8);
63 Assert(PG_GETARG_INT32(1) == PG_EUC_KR);
66 UtfToLocal(src, dest, ULmapEUC_KR, NULL,
67 sizeof(ULmapEUC_KR) / sizeof(pg_utf_to_local), 0, PG_EUC_KR, len);