PostgreSQL Source Code git master
Loading...
Searching...
No Matches
utf8_and_euc_tw.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * EUC_TW <--> UTF8
4 *
5 * Portions Copyright (c) 1996-2026, 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_tw/utf8_and_euc_tw.c
10 *
11 *-------------------------------------------------------------------------
12 */
13
14#include "postgres.h"
15#include "fmgr.h"
16#include "mb/pg_wchar.h"
17#include "../../Unicode/euc_tw_to_utf8.map"
18#include "../../Unicode/utf8_to_euc_tw.map"
19
21 .name = "utf8_and_euc_tw",
22 .version = PG_VERSION
23);
24
27
28/* ----------
29 * conv_proc(
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
35 * BOOL -- if true, don't throw an error if conversion fails
36 * ) returns INTEGER;
37 *
38 * Returns the number of bytes successfully converted.
39 * ----------
40 */
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,
54 NULL, 0,
55 NULL,
57 noError);
58
60}
61
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,
75 NULL, 0,
76 NULL,
78 noError);
79
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
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_MODULE_MAGIC_EXT(...)
Definition fmgr.h:540
#define PG_GETARG_CSTRING(n)
Definition fmgr.h:278
#define PG_FUNCTION_INFO_V1(funcname)
Definition fmgr.h:417
#define PG_RETURN_INT32(x)
Definition fmgr.h:355
#define PG_GETARG_INT32(n)
Definition fmgr.h:269
#define PG_GETARG_BOOL(n)
Definition fmgr.h:274
#define PG_FUNCTION_ARGS
Definition fmgr.h:193
#define PG_UTF8
Definition mbprint.c:43
const void size_t len
@ PG_EUC_TW
Definition pg_wchar.h:230
#define CHECK_ENCODING_CONVERSION_ARGS(srcencoding, destencoding)
Definition pg_wchar.h:507
uint64_t Datum
Definition postgres.h:70
static int fb(int x)
Datum euc_tw_to_utf8(PG_FUNCTION_ARGS)
Datum utf8_to_euc_tw(PG_FUNCTION_ARGS)
const char * name