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 36 of file utf8_and_sjis2004.c.

References CHECK_ENCODING_CONVERSION_ARGS, generate_unaccent_rules::dest, lengthof, LocalToUtf(), PG_GETARG_CSTRING, PG_GETARG_INT32, PG_RETURN_VOID, PG_SHIFT_JIS_2004, 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  &shift_jis_2004_to_unicode_tree,
46  LUmapSHIFT_JIS_2004_combined, lengthof(LUmapSHIFT_JIS_2004_combined),
47  NULL,
49 
51 }
#define PG_GETARG_INT32(n)
Definition: fmgr.h:234
#define lengthof(array)
Definition: c.h:600
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:666
#define PG_RETURN_VOID()
Definition: fmgr.h:309
#define CHECK_ENCODING_CONVERSION_ARGS(srcencoding, destencoding)
Definition: pg_wchar.h:503
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:242

◆ utf8_to_shift_jis_2004()

Datum utf8_to_shift_jis_2004 ( PG_FUNCTION_ARGS  )

Definition at line 54 of file utf8_and_sjis2004.c.

References CHECK_ENCODING_CONVERSION_ARGS, generate_unaccent_rules::dest, lengthof, PG_GETARG_CSTRING, PG_GETARG_INT32, PG_RETURN_VOID, PG_SHIFT_JIS_2004, 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  &shift_jis_2004_from_unicode_tree,
64  ULmapSHIFT_JIS_2004_combined, lengthof(ULmapSHIFT_JIS_2004_combined),
65  NULL,
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:234
#define lengthof(array)
Definition: c.h:600
#define PG_RETURN_VOID()
Definition: fmgr.h:309
#define CHECK_ENCODING_CONVERSION_ARGS(srcencoding, destencoding)
Definition: pg_wchar.h:503
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:242

Variable Documentation

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 20 of file utf8_and_sjis2004.c.