Datum win1251_to_mic(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_WIN1251, PG_MULE_INTERNAL); win12512mic(src, dest, len); PG_RETURN_VOID(); }
Datum win1251_to_mic(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_WIN1251); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); Assert(len >= 0); win12512mic(src, dest, len); PG_RETURN_VOID(); }
Datum win1251_to_koi8r(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); unsigned char *buf; CHECK_ENCODING_CONVERSION_ARGS(PG_WIN1251, PG_KOI8R); buf = palloc(len * ENCODING_GROWTH_RATE + 1); win12512mic(src, buf, len); mic2koi8r(buf, dest, strlen((char *) buf)); pfree(buf); PG_RETURN_VOID(); }
Datum win1251_to_iso(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); unsigned char *buf; CHECK_ENCODING_CONVERSION_ARGS(PG_WIN1251, PG_ISO_8859_5); /* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */ buf = palloc(len * ENCODING_GROWTH_RATE + 1); win12512mic(src, buf, len); mic2iso(buf, dest, strlen((char *) buf)); pfree(buf); PG_RETURN_VOID(); }
Datum win1251_to_iso(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); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_WIN1251); Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5); Assert(len >= 0); buf = palloc(len * ENCODING_GROWTH_RATE); win12512mic(src, buf, len); mic2iso(buf, dest, strlen((char *) buf)); pfree(buf); PG_RETURN_VOID(); }