Header And Logo

PostgreSQL
| The world's most advanced open source database.

Data Structures | Functions | Variables

utf8_and_iso8859.c File Reference

#include "postgres.h"
#include "fmgr.h"
#include "mb/pg_wchar.h"
#include "../../Unicode/iso8859_10_to_utf8.map"
#include "../../Unicode/iso8859_13_to_utf8.map"
#include "../../Unicode/iso8859_14_to_utf8.map"
#include "../../Unicode/iso8859_15_to_utf8.map"
#include "../../Unicode/iso8859_2_to_utf8.map"
#include "../../Unicode/iso8859_3_to_utf8.map"
#include "../../Unicode/iso8859_4_to_utf8.map"
#include "../../Unicode/iso8859_5_to_utf8.map"
#include "../../Unicode/iso8859_6_to_utf8.map"
#include "../../Unicode/iso8859_7_to_utf8.map"
#include "../../Unicode/iso8859_8_to_utf8.map"
#include "../../Unicode/iso8859_9_to_utf8.map"
#include "../../Unicode/utf8_to_iso8859_10.map"
#include "../../Unicode/utf8_to_iso8859_13.map"
#include "../../Unicode/utf8_to_iso8859_14.map"
#include "../../Unicode/utf8_to_iso8859_15.map"
#include "../../Unicode/utf8_to_iso8859_16.map"
#include "../../Unicode/utf8_to_iso8859_2.map"
#include "../../Unicode/utf8_to_iso8859_3.map"
#include "../../Unicode/utf8_to_iso8859_4.map"
#include "../../Unicode/utf8_to_iso8859_5.map"
#include "../../Unicode/utf8_to_iso8859_6.map"
#include "../../Unicode/utf8_to_iso8859_7.map"
#include "../../Unicode/utf8_to_iso8859_8.map"
#include "../../Unicode/utf8_to_iso8859_9.map"
#include "../../Unicode/iso8859_16_to_utf8.map"
Include dependency graph for utf8_and_iso8859.c:

Go to the source code of this file.

Data Structures

struct  pg_conv_map

Functions

 PG_FUNCTION_INFO_V1 (iso8859_to_utf8)
 PG_FUNCTION_INFO_V1 (utf8_to_iso8859)
Datum iso8859_to_utf8 (PG_FUNCTION_ARGS)
Datum utf8_to_iso8859 (PG_FUNCTION_ARGS)

Variables

 PG_MODULE_MAGIC
static pg_conv_map maps []

Function Documentation

Datum iso8859_to_utf8 ( PG_FUNCTION_ARGS   ) 

Definition at line 115 of file utf8_and_iso8859.c.

References CHECK_ENCODING_CONVERSION_ARGS, encoding, ereport, errcode(), errmsg(), ERROR, i, LocalToUtf(), NULL, PG_GETARG_CSTRING, PG_GETARG_INT32, PG_RETURN_VOID, and PG_UTF8.

{
    int         encoding = PG_GETARG_INT32(0);
    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(-1, PG_UTF8);

    for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
    {
        if (encoding == maps[i].encoding)
        {
            LocalToUtf(src, dest, maps[i].map1, NULL, maps[i].size1, 0, encoding, len);
            PG_RETURN_VOID();
        }
    }

    ereport(ERROR,
            (errcode(ERRCODE_INTERNAL_ERROR),
             errmsg("unexpected encoding ID %d for ISO 8859 character sets", encoding)));

    PG_RETURN_VOID();
}

PG_FUNCTION_INFO_V1 ( utf8_to_iso8859   ) 
PG_FUNCTION_INFO_V1 ( iso8859_to_utf8   ) 
Datum utf8_to_iso8859 ( PG_FUNCTION_ARGS   ) 

Definition at line 142 of file utf8_and_iso8859.c.

References CHECK_ENCODING_CONVERSION_ARGS, encoding, ereport, errcode(), errmsg(), ERROR, i, NULL, PG_GETARG_CSTRING, PG_GETARG_INT32, PG_RETURN_VOID, PG_UTF8, and UtfToLocal().

{
    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 < sizeof(maps) / sizeof(pg_conv_map); i++)
    {
        if (encoding == maps[i].encoding)
        {
            UtfToLocal(src, dest, maps[i].map2, NULL, maps[i].size2, 0, encoding, len);
            PG_RETURN_VOID();
        }
    }

    ereport(ERROR,
            (errcode(ERRCODE_INTERNAL_ERROR),
             errmsg("unexpected encoding ID %d for ISO 8859 character sets", encoding)));

    PG_RETURN_VOID();
}


Variable Documentation

pg_conv_map maps[] [static]

Definition at line 72 of file utf8_and_iso8859.c.

Referenced by gen_db_file_maps().

Definition at line 44 of file utf8_and_iso8859.c.