1 /*-------------------------------------------------------------------------
5 * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
6 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c
11 *-------------------------------------------------------------------------
16 #include "mb/pg_wchar.h"
17 #include "../../Unicode/euc_jp_to_utf8.map"
18 #include "../../Unicode/utf8_to_euc_jp.map"
22 PG_FUNCTION_INFO_V1(euc_jp_to_utf8);
23 PG_FUNCTION_INFO_V1(utf8_to_euc_jp);
25 extern Datum euc_jp_to_utf8(PG_FUNCTION_ARGS);
26 extern Datum utf8_to_euc_jp(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_jp_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 CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_JP, PG_UTF8);
47 LocalToUtf(src, dest, LUmapEUC_JP, NULL,
48 sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), 0, PG_EUC_JP, len);
54 utf8_to_euc_jp(PG_FUNCTION_ARGS)
56 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
57 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
58 int len = PG_GETARG_INT32(4);
60 CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_JP);
62 UtfToLocal(src, dest, ULmapEUC_JP, NULL,
63 sizeof(ULmapEUC_JP) / sizeof(pg_utf_to_local), 0, PG_EUC_JP, len);