Exemplo n.º 1
0
Datum
win866_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_WIN866, PG_MULE_INTERNAL);

	win8662mic(src, dest, len);

	PG_RETURN_VOID();
}
Exemplo n.º 2
0
Datum
win866_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_WIN866);
	Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
	Assert(len >= 0);

	win8662mic(src, dest, len);

	PG_RETURN_VOID();
}
Exemplo n.º 3
0
Datum
win866_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_WIN866, PG_KOI8R);

	buf = palloc(len * ENCODING_GROWTH_RATE + 1);
	win8662mic(src, buf, len);
	mic2koi8r(buf, dest, strlen((char *) buf));
	pfree(buf);

	PG_RETURN_VOID();
}
Exemplo n.º 4
0
Datum
win866_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_WIN866, PG_ISO_8859_5);

	/* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
	buf = palloc(len * ENCODING_GROWTH_RATE + 1);
	win8662mic(src, buf, len);
	mic2iso(buf, dest, strlen((char *) buf));
	pfree(buf);

	PG_RETURN_VOID();
}
Exemplo n.º 5
0
Datum
win866_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_WIN866);
	Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5);
	Assert(len >= 0);

	buf = palloc(len * ENCODING_GROWTH_RATE);
	win8662mic(src, buf, len);
	mic2iso(buf, dest, strlen((char *) buf));
	pfree(buf);

	PG_RETURN_VOID();
}
Exemplo n.º 6
0
Datum
win866_to_win1251(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_WIN866, PG_WIN1251);

	/*
	 * Note: There are a few characters like the "Numero" sign that exist in
	 * all the other cyrillic encodings (win1251, ISO_8859-5 and cp866), but
	 * not in KOI8R. As we use MULE_INTERNAL/KOI8R as an intermediary, we will
	 * fail to convert those characters.
	 */
	buf = palloc(len * ENCODING_GROWTH_RATE + 1);
	win8662mic(src, buf, len);
	mic2win1251(buf, dest, strlen((char *) buf));
	pfree(buf);

	PG_RETURN_VOID();
}