PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
utf8_and_gbk.c File Reference
#include "postgres.h"
#include "fmgr.h"
#include "mb/pg_wchar.h"
#include "../../Unicode/gbk_to_utf8.map"
#include "../../Unicode/utf8_to_gbk.map"
Include dependency graph for utf8_and_gbk.c:

Go to the source code of this file.

Functions

 PG_FUNCTION_INFO_V1 (gbk_to_utf8)
 
 PG_FUNCTION_INFO_V1 (utf8_to_gbk)
 
Datum gbk_to_utf8 (PG_FUNCTION_ARGS)
 
Datum utf8_to_gbk (PG_FUNCTION_ARGS)
 

Variables

 PG_MODULE_MAGIC
 

Function Documentation

Datum gbk_to_utf8 ( PG_FUNCTION_ARGS  )

Definition at line 36 of file utf8_and_gbk.c.

References CHECK_ENCODING_CONVERSION_ARGS, LocalToUtf(), NULL, PG_GBK, PG_GETARG_CSTRING, PG_GETARG_INT32, PG_RETURN_VOID, and PG_UTF8.

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  &gbk_to_unicode_tree,
46  NULL, 0,
47  NULL,
48  PG_GBK);
49 
51 }
#define PG_GETARG_INT32(n)
Definition: fmgr.h:226
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:665
#define PG_RETURN_VOID()
Definition: fmgr.h:301
#define NULL
Definition: c.h:229
#define CHECK_ENCODING_CONVERSION_ARGS(srcencoding, destencoding)
Definition: pg_wchar.h:490
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:234
PG_FUNCTION_INFO_V1 ( gbk_to_utf8  )
PG_FUNCTION_INFO_V1 ( utf8_to_gbk  )
Datum utf8_to_gbk ( PG_FUNCTION_ARGS  )

Definition at line 54 of file utf8_and_gbk.c.

References CHECK_ENCODING_CONVERSION_ARGS, NULL, PG_GBK, PG_GETARG_CSTRING, PG_GETARG_INT32, PG_RETURN_VOID, PG_UTF8, and UtfToLocal().

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  &gbk_from_unicode_tree,
64  NULL, 0,
65  NULL,
66  PG_GBK);
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:226
#define PG_RETURN_VOID()
Definition: fmgr.h:301
#define NULL
Definition: c.h:229
#define CHECK_ENCODING_CONVERSION_ARGS(srcencoding, destencoding)
Definition: pg_wchar.h:490
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:234

Variable Documentation

PG_MODULE_MAGIC

Definition at line 20 of file utf8_and_gbk.c.