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

Go to the source code of this file.

Functions

 PG_FUNCTION_INFO_V1 (utf8_to_koi8r)
 
 PG_FUNCTION_INFO_V1 (koi8r_to_utf8)
 
 PG_FUNCTION_INFO_V1 (utf8_to_koi8u)
 
 PG_FUNCTION_INFO_V1 (koi8u_to_utf8)
 
Datum utf8_to_koi8r (PG_FUNCTION_ARGS)
 
Datum koi8r_to_utf8 (PG_FUNCTION_ARGS)
 
Datum utf8_to_koi8u (PG_FUNCTION_ARGS)
 
Datum koi8u_to_utf8 (PG_FUNCTION_ARGS)
 

Variables

 PG_MODULE_MAGIC
 

Function Documentation

◆ koi8r_to_utf8()

Datum koi8r_to_utf8 ( PG_FUNCTION_ARGS  )

Definition at line 66 of file utf8_and_cyrillic.c.

67{
68 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
69 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
70 int len = PG_GETARG_INT32(4);
71 bool noError = PG_GETARG_BOOL(5);
72 int converted;
73
75
76 converted = LocalToUtf(src, len, dest,
77 &koi8r_to_unicode_tree,
78 NULL, 0,
79 NULL,
81 noError);
82
83 PG_RETURN_INT32(converted);
84}
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_KOI8R
Definition: pg_wchar.h:248
@ PG_UTF8
Definition: pg_wchar.h:232
#define CHECK_ENCODING_CONVERSION_ARGS(srcencoding, destencoding)
Definition: pg_wchar.h:507

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

◆ koi8u_to_utf8()

Datum koi8u_to_utf8 ( PG_FUNCTION_ARGS  )

Definition at line 108 of file utf8_and_cyrillic.c.

109{
110 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
111 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
112 int len = PG_GETARG_INT32(4);
113 bool noError = PG_GETARG_BOOL(5);
114 int converted;
115
117
118 converted = LocalToUtf(src, len, dest,
119 &koi8u_to_unicode_tree,
120 NULL, 0,
121 NULL,
122 PG_KOI8U,
123 noError);
124
125 PG_RETURN_INT32(converted);
126}
@ PG_KOI8U
Definition: pg_wchar.h:260

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

◆ PG_FUNCTION_INFO_V1() [1/4]

PG_FUNCTION_INFO_V1 ( koi8r_to_utf8  )

◆ PG_FUNCTION_INFO_V1() [2/4]

PG_FUNCTION_INFO_V1 ( koi8u_to_utf8  )

◆ PG_FUNCTION_INFO_V1() [3/4]

PG_FUNCTION_INFO_V1 ( utf8_to_koi8r  )

◆ PG_FUNCTION_INFO_V1() [4/4]

PG_FUNCTION_INFO_V1 ( utf8_to_koi8u  )

◆ utf8_to_koi8r()

Datum utf8_to_koi8r ( PG_FUNCTION_ARGS  )

Definition at line 45 of file utf8_and_cyrillic.c.

46{
47 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
48 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
49 int len = PG_GETARG_INT32(4);
50 bool noError = PG_GETARG_BOOL(5);
51 int converted;
52
54
55 converted = UtfToLocal(src, len, dest,
56 &koi8r_from_unicode_tree,
57 NULL, 0,
58 NULL,
60 noError);
61
62 PG_RETURN_INT32(converted);
63}
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_GETARG_BOOL, PG_GETARG_CSTRING, PG_GETARG_INT32, PG_KOI8R, PG_RETURN_INT32, PG_UTF8, and UtfToLocal().

◆ utf8_to_koi8u()

Datum utf8_to_koi8u ( PG_FUNCTION_ARGS  )

Definition at line 87 of file utf8_and_cyrillic.c.

88{
89 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
90 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
91 int len = PG_GETARG_INT32(4);
92 bool noError = PG_GETARG_BOOL(5);
93 int converted;
94
96
97 converted = UtfToLocal(src, len, dest,
98 &koi8u_from_unicode_tree,
99 NULL, 0,
100 NULL,
101 PG_KOI8U,
102 noError);
103
104 PG_RETURN_INT32(converted);
105}

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

Variable Documentation

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 22 of file utf8_and_cyrillic.c.