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/big5_to_utf8.map"
00018 #include "../../Unicode/utf8_to_big5.map"
00019
00020 PG_MODULE_MAGIC;
00021
00022 PG_FUNCTION_INFO_V1(big5_to_utf8);
00023 PG_FUNCTION_INFO_V1(utf8_to_big5);
00024
00025 extern Datum big5_to_utf8(PG_FUNCTION_ARGS);
00026 extern Datum utf8_to_big5(PG_FUNCTION_ARGS);
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 Datum
00039 big5_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_BIG5, PG_UTF8);
00046
00047 LocalToUtf(src, dest, LUmapBIG5, NULL,
00048 sizeof(LUmapBIG5) / sizeof(pg_local_to_utf), 0, PG_BIG5, len);
00049
00050 PG_RETURN_VOID();
00051 }
00052
00053 Datum
00054 utf8_to_big5(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_BIG5);
00061
00062 UtfToLocal(src, dest, ULmapBIG5, NULL,
00063 sizeof(ULmapBIG5) / sizeof(pg_utf_to_local), 0, PG_BIG5, len);
00064
00065 PG_RETURN_VOID();
00066 }