PostgreSQL Source Code git master
utf8_and_big5.c File Reference
#include "postgres.h"
#include "fmgr.h"
#include "mb/pg_wchar.h"
#include "../../Unicode/big5_to_utf8.map"
#include "../../Unicode/utf8_to_big5.map"
Include dependency graph for utf8_and_big5.c:

Go to the source code of this file.

Functions

 PG_MODULE_MAGIC_EXT (.name="utf8_and_big5",.version=PG_VERSION)
 
 PG_FUNCTION_INFO_V1 (big5_to_utf8)
 
 PG_FUNCTION_INFO_V1 (utf8_to_big5)
 
Datum big5_to_utf8 (PG_FUNCTION_ARGS)
 
Datum utf8_to_big5 (PG_FUNCTION_ARGS)
 

Function Documentation

◆ big5_to_utf8()

Datum big5_to_utf8 ( PG_FUNCTION_ARGS  )

Definition at line 42 of file utf8_and_big5.c.

43{
44 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
45 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
46 int len = PG_GETARG_INT32(4);
47 bool noError = PG_GETARG_BOOL(5);
48 int converted;
49
51
52 converted = LocalToUtf(src, len, dest,
53 &big5_to_unicode_tree,
54 NULL, 0,
55 NULL,
56 PG_BIG5,
57 noError);
58
59 PG_RETURN_INT32(converted);
60}
int 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, bool noError)
Definition: conv.c:717
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:277
#define PG_RETURN_INT32(x)
Definition: fmgr.h:354
#define PG_GETARG_INT32(n)
Definition: fmgr.h:269
#define PG_GETARG_BOOL(n)
Definition: fmgr.h:274
const void size_t len
@ PG_UTF8
Definition: pg_wchar.h:232
@ PG_BIG5
Definition: pg_wchar.h:265
#define CHECK_ENCODING_CONVERSION_ARGS(srcencoding, destencoding)
Definition: pg_wchar.h:507

References CHECK_ENCODING_CONVERSION_ARGS, generate_unaccent_rules::dest, len, LocalToUtf(), PG_BIG5, PG_GETARG_BOOL, PG_GETARG_CSTRING, PG_GETARG_INT32, PG_RETURN_INT32, and PG_UTF8.

◆ PG_FUNCTION_INFO_V1() [1/2]

PG_FUNCTION_INFO_V1 ( big5_to_utf8  )

◆ PG_FUNCTION_INFO_V1() [2/2]

PG_FUNCTION_INFO_V1 ( utf8_to_big5  )

◆ PG_MODULE_MAGIC_EXT()

PG_MODULE_MAGIC_EXT ( name = "utf8_and_big5",
version = PG_VERSION 
)

◆ utf8_to_big5()

Datum utf8_to_big5 ( PG_FUNCTION_ARGS  )

Definition at line 63 of file utf8_and_big5.c.

64{
65 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
66 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
67 int len = PG_GETARG_INT32(4);
68 bool noError = PG_GETARG_BOOL(5);
69 int converted;
70
72
73 converted = UtfToLocal(src, len, dest,
74 &big5_from_unicode_tree,
75 NULL, 0,
76 NULL,
77 PG_BIG5,
78 noError);
79
80 PG_RETURN_INT32(converted);
81}
int 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, bool noError)
Definition: conv.c:507

References CHECK_ENCODING_CONVERSION_ARGS, generate_unaccent_rules::dest, len, PG_BIG5, PG_GETARG_BOOL, PG_GETARG_CSTRING, PG_GETARG_INT32, PG_RETURN_INT32, PG_UTF8, and UtfToLocal().