Commit 7730f48e authored by Tom Lane's avatar Tom Lane

Teach UtfToLocal/LocalToUtf to support algorithmic encoding conversions.

Until now, these functions have only supported encoding conversions using
lookup tables, which is fine as long as there's not too many code points
to convert.  However, GB18030 expects all 1.1 million Unicode code points
to be convertible, which would require a ridiculously-sized lookup table.
Fortunately, a large fraction of those conversions can be expressed through
arithmetic, ie the conversions are one-to-one in certain defined ranges.
To support that, provide a callback function that is used after consulting
the lookup tables.  (This patch doesn't actually change anything about the
GB18030 conversion behavior, just provide infrastructure for fixing it.)

Since this requires changing the APIs of UtfToLocal/LocalToUtf anyway,
take the opportunity to rearrange their argument lists into what seems
to me a saner order.  And beautify the call sites by using lengthof()
instead of error-prone sizeof() arithmetic.

In passing, also mark all the lookup tables used by these calls "const".
This moves an impressive amount of stuff into the text segment, at least
on my machine, and is safer anyhow.
parent 83e176ec
......@@ -97,7 +97,7 @@ close(FILE);
$file = lc("utf8_to_big5.map");
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapBIG5[ $count ] = {\n";
print FILE "static const pg_utf_to_local ULmapBIG5[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -185,7 +185,7 @@ close(FILE);
$file = lc("big5_to_utf8.map");
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapBIG5[ $count ] = {\n";
print FILE "static const pg_local_to_utf LUmapBIG5[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
......
......@@ -55,7 +55,7 @@ close(FILE);
$file = "utf8_to_euc_cn.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapEUC_CN[ $count ] = {\n";
print FILE "static const pg_utf_to_local ULmapEUC_CN[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -109,7 +109,7 @@ close(FILE);
$file = "euc_cn_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapEUC_CN[ $count ] = {\n";
print FILE "static const pg_local_to_utf LUmapEUC_CN[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
......
......@@ -72,7 +72,7 @@ open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_utf_to_local ULmapEUC_JIS_2004[] = {\n";
print FILE "static const pg_utf_to_local ULmapEUC_JIS_2004[] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -133,7 +133,7 @@ print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
print FILE
"static pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[] = {\n";
"static const pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[] = {\n";
for $index (sort { $a cmp $b } keys(%array1))
{
......@@ -256,7 +256,7 @@ open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_local_to_utf LUmapEUC_JIS_2004[] = {\n";
print FILE "static const pg_local_to_utf LUmapEUC_JIS_2004[] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -283,7 +283,7 @@ print FILE "/*\n";
print FILE " * This file was generated by UCS_to_EUC_JIS_2004.pl\n";
print FILE " */\n";
print FILE
"static pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[] = {\n";
"static const pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[] = {\n";
for $index (sort { $a <=> $b } keys(%array1))
{
......
......@@ -136,7 +136,7 @@ close(FILE);
$file = "utf8_to_euc_jp.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapEUC_JP[ $count ] = {\n";
print FILE "static const pg_utf_to_local ULmapEUC_JP[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -263,7 +263,7 @@ close(FILE);
$file = "euc_jp_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapEUC_JP[ $count ] = {\n";
print FILE "static const pg_local_to_utf LUmapEUC_JP[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
......
......@@ -55,7 +55,7 @@ close(FILE);
$file = "utf8_to_euc_kr.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapEUC_KR[ $count ] = {\n";
print FILE "static const pg_utf_to_local ULmapEUC_KR[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -109,7 +109,7 @@ close(FILE);
$file = "euc_kr_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapEUC_KR[ $count ] = {\n";
print FILE "static const pg_local_to_utf LUmapEUC_KR[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
......
......@@ -71,7 +71,7 @@ close(FILE);
$file = "utf8_to_euc_tw.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapEUC_TW[ $count ] = {\n";
print FILE "static const pg_utf_to_local ULmapEUC_TW[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -138,7 +138,7 @@ close(FILE);
$file = "euc_tw_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapEUC_TW[ $count ] = {\n";
print FILE "static const pg_local_to_utf LUmapEUC_TW[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
......
......@@ -52,7 +52,7 @@ close(FILE);
$file = "utf8_to_gb18030.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapGB18030[ $count ] = {\n";
print FILE "static const pg_utf_to_local ULmapGB18030[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -106,7 +106,7 @@ close(FILE);
$file = "gb18030_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapGB18030[ $count ] = {\n";
print FILE "static const pg_local_to_utf LUmapGB18030[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
......
......@@ -72,7 +72,7 @@ open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFT_JIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_utf_to_local ULmapSHIFT_JIS_2004[] = {\n";
print FILE "static const pg_utf_to_local ULmapSHIFT_JIS_2004[] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -99,7 +99,7 @@ print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFT_JIS_2004.pl\n";
print FILE " */\n";
print FILE
"static pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[] = {\n";
"static const pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[] = {\n";
for $index (sort { $a cmp $b } keys(%array1))
{
......@@ -185,7 +185,7 @@ open(FILE, "> $file") || die("cannot open $file");
print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFTJIS_2004.pl\n";
print FILE " */\n";
print FILE "static pg_local_to_utf LUmapSHIFT_JIS_2004[] = {\n";
print FILE "static const pg_local_to_utf LUmapSHIFT_JIS_2004[] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -212,7 +212,7 @@ print FILE "/*\n";
print FILE " * This file was generated by UCS_to_SHIFT_JIS_2004.pl\n";
print FILE " */\n";
print FILE
"static pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = {\n";
"static const pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = {\n";
for $index (sort { $a <=> $b } keys(%array1))
{
......
......@@ -72,7 +72,7 @@ close(FILE);
$file = "utf8_to_sjis.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapSJIS[ $count ] = {\n";
print FILE "static const pg_utf_to_local ULmapSJIS[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -122,7 +122,7 @@ close(FILE);
$file = "sjis_to_utf8.map";
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapSJIS[ $count ] = {\n";
print FILE "static const pg_local_to_utf LUmapSJIS[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
......
......@@ -88,7 +88,7 @@ foreach $charset (@charsets)
$file = lc("utf8_to_${charset}.map");
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmap${charset}[ $count ] = {\n";
print FILE "static const pg_utf_to_local ULmap${charset}[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
......@@ -140,7 +140,7 @@ foreach $charset (@charsets)
$file = lc("${charset}_to_utf8.map");
open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmap${charset}[ $count ] = {\n";
print FILE "static const pg_local_to_utf LUmap${charset}[ $count ] = {\n";
for $index (sort { $a <=> $b } keys(%array))
{
$utf = $array{$index};
......
static pg_local_to_utf LUmapBIG5[ 13717 ] = {
static const pg_local_to_utf LUmapBIG5[ 13717 ] = {
{0xa140, 0xe38080},
{0xa141, 0xefbc8c},
{0xa142, 0xe38081},
......
/* src/backend/utils/mb/Unicode/euc_cn_to_utf8.map */
static pg_local_to_utf LUmapEUC_CN[ 7445 ] = {
static const pg_local_to_utf LUmapEUC_CN[ 7445 ] = {
{0xa1a1, 0xe38080},
{0xa1a2, 0xe38081},
{0xa1a3, 0xe38082},
......
/*
* This file was generated by UCS_to_EUC_JIS_2004.pl
*/
static pg_local_to_utf LUmapEUC_JIS_2004[] = {
static const pg_local_to_utf LUmapEUC_JIS_2004[] = {
{0x000000, 0x00000000}, /* U+0000 <control> */
{0x000001, 0x00000001}, /* U+0001 <control> */
{0x000002, 0x00000002}, /* U+0002 <control> */
......
/*
* This file was generated by UCS_to_EUC_JIS_2004.pl
*/
static pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[] = {
static const pg_local_to_utf_combined LUmapEUC_JIS_2004_combined[] = {
{0x00a4f7, 0x00e3818b, 0x00e3829a}, /* U+304B+309A [2000] */
{0x00a4f8, 0x00e3818d, 0x00e3829a}, /* U+304D+309A [2000] */
{0x00a4f9, 0x00e3818f, 0x00e3829a}, /* U+304F+309A [2000] */
......
/* src/backend/utils/mb/Unicode/euc_jp_to_utf8.map */
static pg_local_to_utf LUmapEUC_JP[] = {
static const pg_local_to_utf LUmapEUC_JP[] = {
{0x8ea1, 0xefbda1},
{0x8ea2, 0xefbda2},
{0x8ea3, 0xefbda3},
......
static pg_local_to_utf LUmapEUC_KR[ 8227 ] = {
static const pg_local_to_utf LUmapEUC_KR[ 8227 ] = {
{0xa1a1, 0xe38080},
{0xa1a2, 0xe38081},
{0xa1a3, 0xe38082},
......
/* src/backend/utils/mb/Unicode/euc_tw_to_utf8.map */
static pg_local_to_utf LUmapEUC_TW[ 23575 ] = {
static const pg_local_to_utf LUmapEUC_TW[ 23575 ] = {
{0xa1a1, 0xe38080},
{0xa1a2, 0xefbc8c},
{0xa1a3, 0xe38081},
......
/* src/backend/utils/mb/Unicode/gb18030_to_utf8.map */
static pg_local_to_utf LUmapGB18030[ 63360 ] = {
static const pg_local_to_utf LUmapGB18030[ 63360 ] = {
{0x8140, 0xe4b882},
{0x8141, 0xe4b884},
{0x8142, 0xe4b885},
/* src/backend/utils/mb/Unicode/gbk_to_utf8.map */
static pg_local_to_utf LUmapGBK[ 21792 ] = {
static const pg_local_to_utf LUmapGBK[ 21792 ] = {
{0x0080, 0xe282ac},
{0x8140, 0xe4b882},
{0x8141, 0xe4b884},
......
/* src/backend/utils/mb/Unicode/iso8859_10_to_utf8.map */
static pg_local_to_utf LUmapISO8859_10[ 128 ] = {
static const pg_local_to_utf LUmapISO8859_10[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_13_to_utf8.map */
static pg_local_to_utf LUmapISO8859_13[ 128 ] = {
static const pg_local_to_utf LUmapISO8859_13[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_14_to_utf8.map */
static pg_local_to_utf LUmapISO8859_14[ 128 ] = {
static const pg_local_to_utf LUmapISO8859_14[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_15_to_utf8.map */
static pg_local_to_utf LUmapISO8859_15[ 128 ] = {
static const pg_local_to_utf LUmapISO8859_15[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_16_to_utf8.map */
static pg_local_to_utf LUmapISO8859_16[ 128 ] = {
static const pg_local_to_utf LUmapISO8859_16[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_2_to_utf8.map */
static pg_local_to_utf LUmapISO8859_2[ 128 ] = {
static const pg_local_to_utf LUmapISO8859_2[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_3_to_utf8.map */
static pg_local_to_utf LUmapISO8859_3[ 121 ] = {
static const pg_local_to_utf LUmapISO8859_3[ 121 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_4_to_utf8.map */
static pg_local_to_utf LUmapISO8859_4[ 128 ] = {
static const pg_local_to_utf LUmapISO8859_4[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_5_to_utf8.map */
static pg_local_to_utf LUmapISO8859_5[ 128 ] = {
static const pg_local_to_utf LUmapISO8859_5[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_6_to_utf8.map */
static pg_local_to_utf LUmapISO8859_6[ 83 ] = {
static const pg_local_to_utf LUmapISO8859_6[ 83 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_7_to_utf8.map */
static pg_local_to_utf LUmapISO8859_7[ 125 ] = {
static const pg_local_to_utf LUmapISO8859_7[ 125 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_8_to_utf8.map */
static pg_local_to_utf LUmapISO8859_8[ 92 ] = {
static const pg_local_to_utf LUmapISO8859_8[ 92 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
/* src/backend/utils/mb/Unicode/iso8859_9_to_utf8.map */
static pg_local_to_utf LUmapISO8859_9[ 128 ] = {
static const pg_local_to_utf LUmapISO8859_9[ 128 ] = {
{0x0080, 0xc280},
{0x0081, 0xc281},
{0x0082, 0xc282},
......
static pg_local_to_utf LUmapJOHAB[ 17049 ] = {
static const pg_local_to_utf LUmapJOHAB[ 17049 ] = {
{0x8444, 0xe384b3},
{0x8446, 0xe384b5},
{0x8447, 0xe384b6},
......
/* src/backend/utils/mb/Unicode/koi8r_to_utf8.map */
static pg_local_to_utf LUmapKOI8R[ 128 ] = {
static const pg_local_to_utf LUmapKOI8R[ 128 ] = {
{0x0080, 0xe29480},
{0x0081, 0xe29482},
{0x0082, 0xe2948c},
......
static pg_local_to_utf LUmapKOI8U[ 128 ] = {
static const pg_local_to_utf LUmapKOI8U[ 128 ] = {
{0x0080, 0xe29480},
{0x0081, 0xe29482},
{0x0082, 0xe2948c},
......
/*
* This file was generated by UCS_to_SHIFTJIS_2004.pl
*/
static pg_local_to_utf LUmapSHIFT_JIS_2004[] = {
static const pg_local_to_utf LUmapSHIFT_JIS_2004[] = {
{0x0000, 0x00000000}, /* U+0000 <control> */
{0x0001, 0x00000001}, /* U+0001 <control> */
{0x0002, 0x00000002}, /* U+0002 <control> */
......
/*
* This file was generated by UCS_to_SHIFT_JIS_2004.pl
*/
static pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = {
static const pg_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = {
{0x82f5, 0x00e3818b, 0x00e3829a}, /* U+304B+309A [2000] */
{0x82f6, 0x00e3818d, 0x00e3829a}, /* U+304D+309A [2000] */
{0x82f7, 0x00e3818f, 0x00e3829a}, /* U+304F+309A [2000] */
......
static pg_local_to_utf LUmapSJIS[ 7787 ] = {
static const pg_local_to_utf LUmapSJIS[ 7787 ] = {
{0x00a1, 0xefbda1},
{0x00a2, 0xefbda2},
{0x00a3, 0xefbda3},
......
static pg_local_to_utf LUmapUHC[ 17237 ] = {
static const pg_local_to_utf LUmapUHC[ 17237 ] = {
{0x8141, 0xeab082},
{0x8142, 0xeab083},
{0x8143, 0xeab085},
......
static pg_utf_to_local ULmapBIG5[ 13711 ] = {
static const pg_utf_to_local ULmapBIG5[ 13711 ] = {
{0xc2a2, 0xa246},
{0xc2a3, 0xa247},
{0xc2a5, 0xa244},
......
static pg_utf_to_local ULmapEUC_CN[ 7445 ] = {
static const pg_utf_to_local ULmapEUC_CN[ 7445 ] = {
{0xc2a4, 0xa1e8},
{0xc2a7, 0xa1ec},
{0xc2a8, 0xa1a7},
......
/*
* This file was generated by UCS_to_EUC_JIS_2004.pl
*/
static pg_utf_to_local ULmapEUC_JIS_2004[] = {
static const pg_utf_to_local ULmapEUC_JIS_2004[] = {
{0x00000000, 0x000000}, /* U+0000 <control> */
{0x00000001, 0x000001}, /* U+0001 <control> */
{0x00000002, 0x000002}, /* U+0002 <control> */
......
/*
* This file was generated by UCS_to_EUC_JIS_2004.pl
*/
static pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[] = {
static const pg_utf_to_local_combined ULmapEUC_JIS_2004_combined[] = {
{0x0000c3a6, 0x0000cc80, 0x00abc4}, /* U+00E6+0300 [2000] */
{0x0000c994, 0x0000cc80, 0x00abc8}, /* U+0254+0300 [2000] */
{0x0000c994, 0x0000cc81, 0x00abc9}, /* U+0254+0301 [2000] */
......
static pg_utf_to_local ULmapEUC_JP[ 13175 ] = {
static const pg_utf_to_local ULmapEUC_JP[ 13175 ] = {
{0xc2a1, 0x8fa2c2},
{0xc2a4, 0x8fa2f0},
{0xc2a6, 0x8fa2c3},
......
static pg_utf_to_local ULmapEUC_KR[ 8227 ] = {
static const pg_utf_to_local ULmapEUC_KR[ 8227 ] = {
{0xc2a1, 0xa2ae},
{0xc2a4, 0xa2b4},
{0xc2a7, 0xa1d7},
......
static pg_utf_to_local ULmapEUC_TW[ 17711 ] = {
static const pg_utf_to_local ULmapEUC_TW[ 17711 ] = {
{0xc2a7, 0xa1f0},
{0xc2b0, 0xa2f8},
{0xc2b1, 0xa2b4},
......
static pg_utf_to_local ULmapGB18030[ 63360 ] = {
static const pg_utf_to_local ULmapGB18030[ 63360 ] = {
{0xc280, 0x81308130},
{0xc281, 0x81308131},
{0xc282, 0x81308132},
static pg_utf_to_local ULmapGBK[ 21792 ] = {
static const pg_utf_to_local ULmapGBK[ 21792 ] = {
{0xc2a4, 0xa1e8},
{0xc2a7, 0xa1ec},
{0xc2a8, 0xa1a7},
......
static pg_utf_to_local ULmapISO8859_10[ 128 ] = {
static const pg_utf_to_local ULmapISO8859_10[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_13[ 128 ] = {
static const pg_utf_to_local ULmapISO8859_13[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_14[ 128 ] = {
static const pg_utf_to_local ULmapISO8859_14[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_15[ 128 ] = {
static const pg_utf_to_local ULmapISO8859_15[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_16[ 128 ] = {
static const pg_utf_to_local ULmapISO8859_16[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_2[ 128 ] = {
static const pg_utf_to_local ULmapISO8859_2[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_3[ 121 ] = {
static const pg_utf_to_local ULmapISO8859_3[ 121 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_4[ 128 ] = {
static const pg_utf_to_local ULmapISO8859_4[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_5[ 128 ] = {
static const pg_utf_to_local ULmapISO8859_5[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_6[ 83 ] = {
static const pg_utf_to_local ULmapISO8859_6[ 83 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_7[ 125 ] = {
static const pg_utf_to_local ULmapISO8859_7[ 125 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_8[ 92 ] = {
static const pg_utf_to_local ULmapISO8859_8[ 92 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapISO8859_9[ 128 ] = {
static const pg_utf_to_local ULmapISO8859_9[ 128 ] = {
{0xc280, 0x0080},
{0xc281, 0x0081},
{0xc282, 0x0082},
......
static pg_utf_to_local ULmapJOHAB[ 17049 ] = {
static const pg_utf_to_local ULmapJOHAB[ 17049 ] = {
{0xc2a1, 0xd9ae},
{0xc2a4, 0xd9b4},
{0xc2a7, 0xd967},
......
static pg_utf_to_local ULmapKOI8R[ 128 ] = {
static const pg_utf_to_local ULmapKOI8R[ 128 ] = {
{0xc2a0, 0x009a},
{0xc2a9, 0x00bf},
{0xc2b0, 0x009c},
......
static pg_utf_to_local ULmapKOI8U[ 128 ] = {
static const pg_utf_to_local ULmapKOI8U[ 128 ] = {
{0xc2a0, 0x009a},
{0xc2a9, 0x00bf},
{0xc2b0, 0x009c},
......
/*
* This file was generated by UCS_to_SHIFT_JIS_2004.pl
*/
static pg_utf_to_local ULmapSHIFT_JIS_2004[] = {
static const pg_utf_to_local ULmapSHIFT_JIS_2004[] = {
{0x00000000, 0x000000}, /* U+0000 <control> */
{0x00000001, 0x000001}, /* U+0001 <control> */
{0x00000002, 0x000002}, /* U+0002 <control> */
......
/*
* This file was generated by UCS_to_SHIFT_JIS_2004.pl
*/
static pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[] = {
static const pg_utf_to_local_combined ULmapSHIFT_JIS_2004_combined[] = {
{0x0000c3a6, 0x0000cc80, 0x8663}, /* U+00E6+0300 [2000] */
{0x0000c994, 0x0000cc80, 0x8667}, /* U+0254+0300 [2000] */
{0x0000c994, 0x0000cc81, 0x8668}, /* U+0254+0301 [2000] */
......
static pg_utf_to_local ULmapSJIS[ 7398 ] = {
static const pg_utf_to_local ULmapSJIS[ 7398 ] = {
{0xc19c, 0x815f},
{0xc2a2, 0x8191},
{0xc2a3, 0x8192},
......
static pg_utf_to_local ULmapUHC[ 17237 ] = {
static const pg_utf_to_local ULmapUHC[ 17237 ] = {
{0xc2a1, 0xa2ae},
{0xc2a4, 0xa2b4},
{0xc2a7, 0xa1d7},
......
static pg_utf_to_local ULmapWIN1250[ 123 ] = {
static const pg_utf_to_local ULmapWIN1250[ 123 ] = {
{0xc2a0, 0x00a0},
{0xc2a4, 0x00a4},
{0xc2a6, 0x00a6},
......
static pg_utf_to_local ULmapWIN1251[ 127 ] = {
static const pg_utf_to_local ULmapWIN1251[ 127 ] = {
{0xc2a0, 0x00a0},
{0xc2a4, 0x00a4},
{0xc2a6, 0x00a6},
......
static pg_utf_to_local ULmapWIN1252[ 123 ] = {
static const pg_utf_to_local ULmapWIN1252[ 123 ] = {
{0xc2a0, 0x00a0},
{0xc2a1, 0x00a1},
{0xc2a2, 0x00a2},
......
static pg_utf_to_local ULmapWIN1253[ 111 ] = {
static const pg_utf_to_local ULmapWIN1253[ 111 ] = {
{0xc2a0, 0x00a0},
{0xc2a3, 0x00a3},
{0xc2a4, 0x00a4},
......
static pg_utf_to_local ULmapWIN1254[ 121 ] = {
static const pg_utf_to_local ULmapWIN1254[ 121 ] = {
{0xc2a0, 0x00a0},
{0xc2a1, 0x00a1},
{0xc2a2, 0x00a2},
......
static pg_utf_to_local ULmapWIN1255[ 105 ] = {
static const pg_utf_to_local ULmapWIN1255[ 105 ] = {
{0xc2a0, 0x00a0},
{0xc2a1, 0x00a1},
{0xc2a2, 0x00a2},
......
static pg_utf_to_local ULmapWIN1256[ 128 ] = {
static const pg_utf_to_local ULmapWIN1256[ 128 ] = {
{0xc2a0, 0x00a0},
{0xc2a2, 0x00a2},
{0xc2a3, 0x00a3},
......
static pg_utf_to_local ULmapWIN1257[ 116 ] = {
static const pg_utf_to_local ULmapWIN1257[ 116 ] = {
{0xc2a0, 0x00a0},
{0xc2a2, 0x00a2},
{0xc2a3, 0x00a3},
......
static pg_utf_to_local ULmapWIN1258[ 119 ] = {
static const pg_utf_to_local ULmapWIN1258[ 119 ] = {
{0xc2a0, 0x00a0},
{0xc2a1, 0x00a1},
{0xc2a2, 0x00a2},
......
static pg_utf_to_local ULmapWIN866[ 128 ] = {
static const pg_utf_to_local ULmapWIN866[ 128 ] = {
{0xc2a0, 0x00ff},
{0xc2a4, 0x00fd},
{0xc2b0, 0x00f8},
......
static pg_utf_to_local ULmapWIN874[ 97 ] = {
static const pg_utf_to_local ULmapWIN874[ 97 ] = {
{0xc2a0, 0x00a0},
{0xe0b881, 0x00a1},
{0xe0b882, 0x00a2},
......
static pg_local_to_utf LUmapWIN1250[ 123 ] = {
static const pg_local_to_utf LUmapWIN1250[ 123 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0084, 0xe2809e},
......
static pg_local_to_utf LUmapWIN1251[ 127 ] = {
static const pg_local_to_utf LUmapWIN1251[ 127 ] = {
{0x0080, 0xd082},
{0x0081, 0xd083},
{0x0082, 0xe2809a},
......
static pg_local_to_utf LUmapWIN1252[ 123 ] = {
static const pg_local_to_utf LUmapWIN1252[ 123 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0083, 0xc692},
......
static pg_local_to_utf LUmapWIN1253[ 111 ] = {
static const pg_local_to_utf LUmapWIN1253[ 111 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0083, 0xc692},
......
static pg_local_to_utf LUmapWIN1254[ 121 ] = {
static const pg_local_to_utf LUmapWIN1254[ 121 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0083, 0xc692},
......
static pg_local_to_utf LUmapWIN1255[ 105 ] = {
static const pg_local_to_utf LUmapWIN1255[ 105 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0083, 0xc692},
......
static pg_local_to_utf LUmapWIN1256[ 128 ] = {
static const pg_local_to_utf LUmapWIN1256[ 128 ] = {
{0x0080, 0xe282ac},
{0x0081, 0xd9be},
{0x0082, 0xe2809a},
......
static pg_local_to_utf LUmapWIN1257[ 116 ] = {
static const pg_local_to_utf LUmapWIN1257[ 116 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0084, 0xe2809e},
......
static pg_local_to_utf LUmapWIN1258[ 119 ] = {
static const pg_local_to_utf LUmapWIN1258[ 119 ] = {
{0x0080, 0xe282ac},
{0x0082, 0xe2809a},
{0x0083, 0xc692},
......
static pg_local_to_utf LUmapWIN866[ 128 ] = {
static const pg_local_to_utf LUmapWIN866[ 128 ] = {
{0x0080, 0xd090},
{0x0081, 0xd091},
{0x0082, 0xd092},
......
static pg_local_to_utf LUmapWIN874[ 97 ] = {
static const pg_local_to_utf LUmapWIN874[ 97 ] = {
{0x0080, 0xe282ac},
{0x0085, 0xe280a6},
{0x0091, 0xe28098},
......
This diff is collapsed.
......@@ -22,7 +22,7 @@ typedef struct
} codes_t;
/* map Big5 Level 1 to CNS 11643-1992 Plane 1 */
static codes_t big5Level1ToCnsPlane1[25] = { /* range */
static const codes_t big5Level1ToCnsPlane1[25] = { /* range */
{0xA140, 0x2121},
{0xA1F6, 0x2258},
{0xA1F7, 0x2257},
......@@ -51,7 +51,7 @@ static codes_t big5Level1ToCnsPlane1[25] = { /* range */
};
/* map CNS 11643-1992 Plane 1 to Big5 Level 1 */
static codes_t cnsPlane1ToBig5Level1[26] = { /* range */
static const codes_t cnsPlane1ToBig5Level1[26] = { /* range */
{0x2121, 0xA140},
{0x2257, 0xA1F7},
{0x2258, 0xA1F6},
......@@ -81,7 +81,7 @@ static codes_t cnsPlane1ToBig5Level1[26] = { /* range */
};
/* map Big5 Level 2 to CNS 11643-1992 Plane 2 */
static codes_t big5Level2ToCnsPlane2[48] = { /* range */
static const codes_t big5Level2ToCnsPlane2[48] = { /* range */
{0xC940, 0x2121},
{0xc94a, 0x0000},
{0xC94B, 0x212B},
......@@ -133,7 +133,7 @@ static codes_t big5Level2ToCnsPlane2[48] = { /* range */
};
/* map CNS 11643-1992 Plane 2 to Big5 Level 2 */
static codes_t cnsPlane2ToBig5Level2[49] = { /* range */
static const codes_t cnsPlane2ToBig5Level2[49] = { /* range */
{0x2121, 0xC940},
{0x212B, 0xC94B},
{0x214C, 0xC9BE},
......@@ -186,7 +186,7 @@ static codes_t cnsPlane2ToBig5Level2[49] = { /* range */
};
/* Big Five Level 1 Correspondence to CNS 11643-1992 Plane 4 */
static unsigned short b1c4[][2] = {
static const unsigned short b1c4[][2] = {
{0xC879, 0x2123},
{0xC87B, 0x2124},
{0xC87D, 0x212A},
......@@ -194,7 +194,7 @@ static unsigned short b1c4[][2] = {
};
/* Big Five Level 2 Correspondence to CNS 11643-1992 Plane 3 */
static unsigned short b2c3[][2] = {
static const unsigned short b2c3[][2] = {
{0xF9D6, 0x4337},
{0xF9D7, 0x4F50},
{0xF9D8, 0x444E},
......@@ -205,7 +205,7 @@ static unsigned short b2c3[][2] = {
};
static unsigned short BinarySearchRange
(codes_t *array, int high, unsigned short code)
(const codes_t *array, int high, unsigned short code)
{
int low,
mid,
......
......@@ -44,8 +44,11 @@ big5_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_BIG5, PG_UTF8);
LocalToUtf(src, dest, LUmapBIG5, NULL,
sizeof(LUmapBIG5) / sizeof(pg_local_to_utf), 0, PG_BIG5, len);
LocalToUtf(src, len, dest,
LUmapBIG5, lengthof(LUmapBIG5),
NULL, 0,
NULL,
PG_BIG5);
PG_RETURN_VOID();
}
......@@ -59,8 +62,11 @@ utf8_to_big5(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_BIG5);
UtfToLocal(src, dest, ULmapBIG5, NULL,
sizeof(ULmapBIG5) / sizeof(pg_utf_to_local), 0, PG_BIG5, len);
UtfToLocal(src, len, dest,
ULmapBIG5, lengthof(ULmapBIG5),
NULL, 0,
NULL,
PG_BIG5);
PG_RETURN_VOID();
}
......@@ -53,8 +53,11 @@ utf8_to_koi8r(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_KOI8R);
UtfToLocal(src, dest, ULmapKOI8R, NULL,
sizeof(ULmapKOI8R) / sizeof(pg_utf_to_local), 0, PG_KOI8R, len);
UtfToLocal(src, len, dest,
ULmapKOI8R, lengthof(ULmapKOI8R),
NULL, 0,
NULL,
PG_KOI8R);
PG_RETURN_VOID();
}
......@@ -68,8 +71,11 @@ koi8r_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_KOI8R, PG_UTF8);
LocalToUtf(src, dest, LUmapKOI8R, NULL,
sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), 0, PG_KOI8R, len);
LocalToUtf(src, len, dest,
LUmapKOI8R, lengthof(LUmapKOI8R),
NULL, 0,
NULL,
PG_KOI8R);
PG_RETURN_VOID();
}
......@@ -83,8 +89,11 @@ utf8_to_koi8u(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_KOI8U);
UtfToLocal(src, dest, ULmapKOI8U, NULL,
sizeof(ULmapKOI8U) / sizeof(pg_utf_to_local), 0, PG_KOI8U, len);
UtfToLocal(src, len, dest,
ULmapKOI8U, lengthof(ULmapKOI8U),
NULL, 0,
NULL,
PG_KOI8U);
PG_RETURN_VOID();
}
......@@ -98,8 +107,11 @@ koi8u_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_KOI8U, PG_UTF8);
LocalToUtf(src, dest, LUmapKOI8U, NULL,
sizeof(LUmapKOI8U) / sizeof(pg_local_to_utf), 0, PG_KOI8U, len);
LocalToUtf(src, len, dest,
LUmapKOI8U, lengthof(LUmapKOI8U),
NULL, 0,
NULL,
PG_KOI8U);
PG_RETURN_VOID();
}
......@@ -46,10 +46,11 @@ euc_jis_2004_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_JIS_2004, PG_UTF8);
LocalToUtf(src, dest, LUmapEUC_JIS_2004, LUmapEUC_JIS_2004_combined,
sizeof(LUmapEUC_JIS_2004) / sizeof(pg_local_to_utf),
sizeof(LUmapEUC_JIS_2004_combined) / sizeof(pg_local_to_utf_combined),
PG_EUC_JIS_2004, len);
LocalToUtf(src, len, dest,
LUmapEUC_JIS_2004, lengthof(LUmapEUC_JIS_2004),
LUmapEUC_JIS_2004_combined, lengthof(LUmapEUC_JIS_2004_combined),
NULL,
PG_EUC_JIS_2004);
PG_RETURN_VOID();
}
......@@ -63,10 +64,11 @@ utf8_to_euc_jis_2004(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_JIS_2004);
UtfToLocal(src, dest, ULmapEUC_JIS_2004, ULmapEUC_JIS_2004_combined,
sizeof(ULmapEUC_JIS_2004) / sizeof(pg_utf_to_local),
sizeof(ULmapEUC_JIS_2004_combined) / sizeof(pg_utf_to_local_combined),
PG_EUC_JIS_2004, len);
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();
}
......@@ -44,8 +44,11 @@ euc_cn_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_CN, PG_UTF8);
LocalToUtf(src, dest, LUmapEUC_CN, NULL,
sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), 0, PG_EUC_CN, len);
LocalToUtf(src, len, dest,
LUmapEUC_CN, lengthof(LUmapEUC_CN),
NULL, 0,
NULL,
PG_EUC_CN);
PG_RETURN_VOID();
}
......@@ -59,8 +62,11 @@ utf8_to_euc_cn(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_CN);
UtfToLocal(src, dest, ULmapEUC_CN, NULL,
sizeof(ULmapEUC_CN) / sizeof(pg_utf_to_local), 0, PG_EUC_CN, len);
UtfToLocal(src, len, dest,
ULmapEUC_CN, lengthof(ULmapEUC_CN),
NULL, 0,
NULL,
PG_EUC_CN);
PG_RETURN_VOID();
}
......@@ -44,8 +44,11 @@ euc_jp_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_JP, PG_UTF8);
LocalToUtf(src, dest, LUmapEUC_JP, NULL,
sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), 0, PG_EUC_JP, len);
LocalToUtf(src, len, dest,
LUmapEUC_JP, lengthof(LUmapEUC_JP),
NULL, 0,
NULL,
PG_EUC_JP);
PG_RETURN_VOID();
}
......@@ -59,8 +62,11 @@ utf8_to_euc_jp(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_JP);
UtfToLocal(src, dest, ULmapEUC_JP, NULL,
sizeof(ULmapEUC_JP) / sizeof(pg_utf_to_local), 0, PG_EUC_JP, len);
UtfToLocal(src, len, dest,
ULmapEUC_JP, lengthof(ULmapEUC_JP),
NULL, 0,
NULL,
PG_EUC_JP);
PG_RETURN_VOID();
}
......@@ -44,8 +44,11 @@ euc_kr_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_KR, PG_UTF8);
LocalToUtf(src, dest, LUmapEUC_KR, NULL,
sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), 0, PG_EUC_KR, len);
LocalToUtf(src, len, dest,
LUmapEUC_KR, lengthof(LUmapEUC_KR),
NULL, 0,
NULL,
PG_EUC_KR);
PG_RETURN_VOID();
}
......@@ -59,8 +62,11 @@ utf8_to_euc_kr(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_KR);
UtfToLocal(src, dest, ULmapEUC_KR, NULL,
sizeof(ULmapEUC_KR) / sizeof(pg_utf_to_local), 0, PG_EUC_KR, len);
UtfToLocal(src, len, dest,
ULmapEUC_KR, lengthof(ULmapEUC_KR),
NULL, 0,
NULL,
PG_EUC_KR);
PG_RETURN_VOID();
}
......@@ -44,8 +44,11 @@ euc_tw_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_EUC_TW, PG_UTF8);
LocalToUtf(src, dest, LUmapEUC_TW, NULL,
sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), 0, PG_EUC_TW, len);
LocalToUtf(src, len, dest,
LUmapEUC_TW, lengthof(LUmapEUC_TW),
NULL, 0,
NULL,
PG_EUC_TW);
PG_RETURN_VOID();
}
......@@ -59,8 +62,11 @@ utf8_to_euc_tw(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_EUC_TW);
UtfToLocal(src, dest, ULmapEUC_TW, NULL,
sizeof(ULmapEUC_TW) / sizeof(pg_utf_to_local), 0, PG_EUC_TW, len);
UtfToLocal(src, len, dest,
ULmapEUC_TW, lengthof(ULmapEUC_TW),
NULL, 0,
NULL,
PG_EUC_TW);
PG_RETURN_VOID();
}
......@@ -44,8 +44,11 @@ gb18030_to_utf8(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_GB18030, PG_UTF8);
LocalToUtf(src, dest, LUmapGB18030, NULL,
sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), 0, PG_GB18030, len);
LocalToUtf(src, len, dest,
LUmapGB18030, lengthof(LUmapGB18030),
NULL, 0,
NULL,
PG_GB18030);
PG_RETURN_VOID();
}
......@@ -59,8 +62,11 @@ utf8_to_gb18030(PG_FUNCTION_ARGS)
CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_GB18030);
UtfToLocal(src, dest, ULmapGB18030, NULL,
sizeof(ULmapGB18030) / sizeof(pg_utf_to_local), 0, PG_GB18030, len);
UtfToLocal(src, len, dest,
ULmapGB18030, lengthof(ULmapGB18030),
NULL, 0,
NULL,
PG_GB18030);
PG_RETURN_VOID();
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment