PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
utf8_and_euc_kr.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * EUC_KR <--> UTF8
4  *
5  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
6  * Portions Copyright (c) 1994, Regents of the University of California
7  *
8  * IDENTIFICATION
9  * src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c
10  *
11  *-------------------------------------------------------------------------
12  */
13 
14 #include "postgres.h"
15 #include "fmgr.h"
16 #include "mb/pg_wchar.h"
17 #include "../../Unicode/euc_kr_to_utf8.map"
18 #include "../../Unicode/utf8_to_euc_kr.map"
19 
21 
24 
25 /* ----------
26  * conv_proc(
27  * INTEGER, -- source encoding id
28  * INTEGER, -- destination encoding id
29  * CSTRING, -- source string (null terminated C string)
30  * CSTRING, -- destination string (null terminated C string)
31  * INTEGER -- source string length
32  * ) returns VOID;
33  * ----------
34  */
35 Datum
37 {
38  unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
39  unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
40  int len = PG_GETARG_INT32(4);
41 
43 
44  LocalToUtf(src, len, dest,
45  &euc_kr_to_unicode_tree,
46  NULL, 0,
47  NULL,
48  PG_EUC_KR);
49 
51 }
52 
53 Datum
55 {
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);
59 
61 
62  UtfToLocal(src, len, dest,
63  &euc_kr_from_unicode_tree,
64  NULL, 0,
65  NULL,
66  PG_EUC_KR);
67 
69 }
void UtfToLocal(const unsigned char *utf, int len, unsigned char *iso, const pg_mb_radix_tree *map, const pg_utf_to_local_combined *cmap, int cmapsize, utf_local_conversion_func conv_func, int encoding)
Definition: conv.c:474
#define PG_GETARG_INT32(n)
Definition: fmgr.h:234
Datum utf8_to_euc_kr(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(euc_kr_to_utf8)
Datum euc_kr_to_utf8(PG_FUNCTION_ARGS)
void LocalToUtf(const unsigned char *iso, int len, unsigned char *utf, const pg_mb_radix_tree *map, const pg_local_to_utf_combined *cmap, int cmapsize, utf_local_conversion_func conv_func, int encoding)
Definition: conv.c:666
uintptr_t Datum
Definition: postgres.h:372
#define PG_RETURN_VOID()
Definition: fmgr.h:309
#define NULL
Definition: c.h:229
#define CHECK_ENCODING_CONVERSION_ARGS(srcencoding, destencoding)
Definition: pg_wchar.h:490
PG_MODULE_MAGIC
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:242
#define PG_FUNCTION_ARGS
Definition: fmgr.h:158