Datum utf8_to_win(PG_FUNCTION_ARGS) { int encoding = PG_GETARG_INT32(1); unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2); unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3); int len = PG_GETARG_INT32(4); int i; Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(len >= 0); for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++) { if (encoding == maps[i].encoding) { UtfToLocal(src, dest, maps[i].map2, maps[i].size2, encoding, len); PG_RETURN_VOID(); } } ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("unexpected encoding ID %d for WIN character sets", encoding))); PG_RETURN_VOID(); }
Datum utf8_to_win(PG_FUNCTION_ARGS) { int encoding = PG_GETARG_INT32(1); unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2); unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3); int len = PG_GETARG_INT32(4); int i; CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, -1); for (i = 0; i < lengthof(maps); i++) { if (encoding == maps[i].encoding) { UtfToLocal(src, len, dest, maps[i].map2, NULL, 0, NULL, encoding); PG_RETURN_VOID(); } } ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("unexpected encoding ID %d for WIN character sets", encoding))); PG_RETURN_VOID(); }
Datum utf8_to_uhc(PG_FUNCTION_ARGS) { unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2); unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3); int len = PG_GETARG_INT32(4); CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_UHC); UtfToLocal(src, dest, ULmapUHC, NULL, sizeof(ULmapUHC) / sizeof(pg_utf_to_local), 0, PG_UHC, len); PG_RETURN_VOID(); }
Datum utf8_to_iso8859(PG_FUNCTION_ARGS) { int encoding = PG_GETARG_INT32(1); unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(len >= 0); UtfToLocal(src, dest, maps[encoding].map2, maps[encoding].size2, encoding, len); PG_RETURN_VOID(); }
Datum utf_to_win1256(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_WIN1256); Assert(len >= 0); UtfToLocal(src, dest, ULmapWIN1256, sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local), PG_WIN1256, len); PG_RETURN_VOID(); }
Datum utf8_to_big5(PG_FUNCTION_ARGS) { unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2); unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3); int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_BIG5); Assert(len >= 0); UtfToLocal(src, dest, ULmapBIG5, sizeof(ULmapBIG5) / sizeof(pg_utf_to_local), len); PG_RETURN_VOID(); }
Datum utf8_to_euc_jp(PG_FUNCTION_ARGS) { unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2); unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3); int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_EUC_JP); Assert(len >= 0); UtfToLocal(src, dest, ULmapEUC_JP, NULL, sizeof(ULmapEUC_JP) / sizeof(pg_utf_to_local), 0, PG_EUC_JP, len); PG_RETURN_VOID(); }
Datum utf8_to_shift_jis_2004(PG_FUNCTION_ARGS) { unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2); unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3); int len = PG_GETARG_INT32(4); CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_SHIFT_JIS_2004); UtfToLocal(src, dest, ULmapSHIFT_JIS_2004, ULmapSHIFT_JIS_2004_combined, sizeof(ULmapSHIFT_JIS_2004) / sizeof(pg_utf_to_local), sizeof(ULmapSHIFT_JIS_2004_combined) / sizeof(pg_utf_to_local_combined), PG_SHIFT_JIS_2004, len); PG_RETURN_VOID(); }
Datum utf8_to_euc_cn(PG_FUNCTION_ARGS) { unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2); unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3); int len = PG_GETARG_INT32(4); CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_CN); UtfToLocal(src, len, dest, &euc_cn_from_unicode_tree, NULL, 0, NULL, PG_EUC_CN); PG_RETURN_VOID(); }
Datum utf8_to_big5(PG_FUNCTION_ARGS) { unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2); unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3); int len = PG_GETARG_INT32(4); CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_BIG5); UtfToLocal(src, len, dest, ULmapBIG5, lengthof(ULmapBIG5), NULL, 0, NULL, PG_BIG5); PG_RETURN_VOID(); }
Datum utf8_to_euc_jis_2004(PG_FUNCTION_ARGS) { unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2); unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3); int len = PG_GETARG_INT32(4); CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_JIS_2004); UtfToLocal(src, len, dest, ULmapEUC_JIS_2004, lengthof(ULmapEUC_JIS_2004), ULmapEUC_JIS_2004_combined, lengthof(ULmapEUC_JIS_2004_combined), NULL, PG_EUC_JIS_2004); PG_RETURN_VOID(); }