Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "postgres.h"
00015 #include "fmgr.h"
00016 #include "mb/pg_wchar.h"
00017 #include "../../Unicode/euc_jp_to_utf8.map"
00018 #include "../../Unicode/utf8_to_euc_jp.map"
00019
00020 PG_MODULE_MAGIC;
00021
00022 PG_FUNCTION_INFO_V1(euc_jp_to_utf8);
00023 PG_FUNCTION_INFO_V1(utf8_to_euc_jp);
00024
00025 extern Datum euc_jp_to_utf8(PG_FUNCTION_ARGS);
00026 extern Datum utf8_to_euc_jp(PG_FUNCTION_ARGS);
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 Datum
00039 euc_jp_to_utf8(PG_FUNCTION_ARGS)
00040 {
00041 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
00042 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
00043 int len = PG_GETARG_INT32(4);
00044
00045 CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_JP, PG_UTF8);
00046
00047 LocalToUtf(src, dest, LUmapEUC_JP, NULL,
00048 sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), 0, PG_EUC_JP, len);
00049
00050 PG_RETURN_VOID();
00051 }
00052
00053 Datum
00054 utf8_to_euc_jp(PG_FUNCTION_ARGS)
00055 {
00056 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
00057 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
00058 int len = PG_GETARG_INT32(4);
00059
00060 CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_JP);
00061
00062 UtfToLocal(src, dest, ULmapEUC_JP, NULL,
00063 sizeof(ULmapEUC_JP) / sizeof(pg_utf_to_local), 0, PG_EUC_JP, len);
00064
00065 PG_RETURN_VOID();
00066 }