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

Go to the source code of this file.

Functions

 PG_FUNCTION_INFO_V1 (shift_jis_2004_to_utf8)
 
 PG_FUNCTION_INFO_V1 (utf8_to_shift_jis_2004)
 
Datum shift_jis_2004_to_utf8 (PG_FUNCTION_ARGS)
 
Datum utf8_to_shift_jis_2004 (PG_FUNCTION_ARGS)
 

Variables

 PG_MODULE_MAGIC
 

Function Documentation

◆ PG_FUNCTION_INFO_V1() [1/2]

PG_FUNCTION_INFO_V1 ( shift_jis_2004_to_utf8  )

◆ PG_FUNCTION_INFO_V1() [2/2]

PG_FUNCTION_INFO_V1 ( utf8_to_shift_jis_2004  )

◆ shift_jis_2004_to_utf8()

Datum shift_jis_2004_to_utf8 ( PG_FUNCTION_ARGS  )

Definition at line 39 of file utf8_and_sjis2004.c.

40 {
41  unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
42  unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
43  int len = PG_GETARG_INT32(4);
44  bool noError = PG_GETARG_BOOL(5);
45  int converted;
46 
48 
49  converted = LocalToUtf(src, len, dest,
50  &shift_jis_2004_to_unicode_tree,
51  LUmapSHIFT_JIS_2004_combined, lengthof(LUmapSHIFT_JIS_2004_combined),
52  NULL,
54  noError);
55 
56  PG_RETURN_INT32(converted);
57 }
#define lengthof(array)
Definition: c.h:788
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_SHIFT_JIS_2004
Definition: pg_wchar.h:270
@ 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, lengthof, LocalToUtf(), PG_GETARG_BOOL, PG_GETARG_CSTRING, PG_GETARG_INT32, PG_RETURN_INT32, PG_SHIFT_JIS_2004, and PG_UTF8.

◆ utf8_to_shift_jis_2004()

Datum utf8_to_shift_jis_2004 ( PG_FUNCTION_ARGS  )

Definition at line 60 of file utf8_and_sjis2004.c.

61 {
62  unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
63  unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
64  int len = PG_GETARG_INT32(4);
65  bool noError = PG_GETARG_BOOL(5);
66  int converted;
67 
69 
70  converted = UtfToLocal(src, len, dest,
71  &shift_jis_2004_from_unicode_tree,
72  ULmapSHIFT_JIS_2004_combined, lengthof(ULmapSHIFT_JIS_2004_combined),
73  NULL,
75  noError);
76 
77  PG_RETURN_INT32(converted);
78 }
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, lengthof, PG_GETARG_BOOL, PG_GETARG_CSTRING, PG_GETARG_INT32, PG_RETURN_INT32, PG_SHIFT_JIS_2004, PG_UTF8, and UtfToLocal().

Variable Documentation

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 20 of file utf8_and_sjis2004.c.