mirror of https://github.com/postgres/postgres
along with new conversions among EUC_JIS_2004, SHIFT_JIS_2004 and UTF-8. catalog version has been bump up.REL8_3_STABLE
parent
7b4726e6c3
commit
75c6519ff6
@ -0,0 +1,248 @@ |
||||
#! /usr/bin/perl |
||||
# |
||||
# Copyright (c) 2007, PostgreSQL Global Development Group |
||||
# |
||||
# $PostgreSQL: pgsql/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl,v 1.1 2007/03/25 11:56:02 ishii Exp $ |
||||
# |
||||
# Generate UTF-8 <--> EUC_JIS_2004 code conversion tables from |
||||
# "euc-jis-2004-std.txt" (http://x0213.org) |
||||
|
||||
require "ucs2utf.pl"; |
||||
|
||||
$TEST = 1; |
||||
|
||||
# first generate UTF-8 --> EUC_JIS_2004 table |
||||
|
||||
$in_file = "euc-jis-2004-std.txt"; |
||||
|
||||
open( FILE, $in_file ) || die( "cannot open $in_file" ); |
||||
|
||||
reset 'array'; |
||||
reset 'array1'; |
||||
reset 'comment'; |
||||
reset 'comment1'; |
||||
|
||||
while($line = <FILE> ){ |
||||
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) { |
||||
$c = $1; |
||||
$u1 = $2; |
||||
$u2 = $3; |
||||
$rest = "U+" . $u1 . "+" . $u2 . $4; |
||||
$code = hex($c); |
||||
$ucs = hex($u1); |
||||
$utf1 = &ucs2utf($ucs); |
||||
$ucs = hex($u2); |
||||
$utf2 = &ucs2utf($ucs); |
||||
$str = sprintf "%08x%08x", $utf1, $utf2; |
||||
$array1{ $str } = $code; |
||||
$comment1{ $str } = $rest; |
||||
$count1++; |
||||
next; |
||||
} elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/) { |
||||
$c = $1; |
||||
$u = $2; |
||||
$rest = "U+" . $u . $3; |
||||
} else { |
||||
next; |
||||
} |
||||
|
||||
$ucs = hex($u); |
||||
$code = hex($c); |
||||
$utf = &ucs2utf($ucs); |
||||
if( $array{ $utf } ne "" ){ |
||||
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs; |
||||
next; |
||||
} |
||||
$count++; |
||||
|
||||
$array{ $utf } = $code; |
||||
$comment{ $code } = $rest; |
||||
} |
||||
close( FILE ); |
||||
|
||||
$file = "utf8_to_euc_jis_2004.map"; |
||||
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"; |
||||
|
||||
for $index ( sort {$a <=> $b} keys( %array ) ){ |
||||
$code = $array{ $index }; |
||||
$count--; |
||||
if( $count == 0 ){ |
||||
printf FILE " {0x%08x, 0x%06x} /* %s */\n", $index, $code, $comment{ $code }; |
||||
} else { |
||||
printf FILE " {0x%08x, 0x%06x}, /* %s */\n", $index, $code, $comment{ $code }; |
||||
} |
||||
} |
||||
|
||||
print FILE "};\n"; |
||||
close(FILE); |
||||
|
||||
if ($TEST == 1) { |
||||
$file1 = "utf8.data"; |
||||
$file2 = "euc_jis_2004.data"; |
||||
open( FILE1, "> $file1" ) || die( "cannot open $file1" ); |
||||
open( FILE2, "> $file2" ) || die( "cannot open $file2" ); |
||||
|
||||
for $index ( sort {$a <=> $b} keys( %array ) ){ |
||||
$code = $array{ $index }; |
||||
if ($code > 0x00 && $code != 0x09 && $code != 0x0a && $code != 0x0d && |
||||
$code != 0x5c && |
||||
($code < 0x80 || |
||||
($code >= 0x8ea1 && $code <= 0x8efe) || |
||||
($code >= 0x8fa1a1 && $code <= 0x8ffefe) || |
||||
($code >= 0xa1a1 && $code <= 0x8fefe))) { |
||||
for ($i = 3; $i >= 0; $i--) { |
||||
$s = $i * 8; |
||||
$mask = 0xff << $s; |
||||
print FILE1 pack("C", ($index & $mask) >> $s) if $index & $mask; |
||||
print FILE2 pack("C", ($code & $mask) >> $s) if $code & $mask; |
||||
} |
||||
print FILE1 "\n"; |
||||
print FILE2 "\n"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
$file = "utf8_to_euc_jis_2004_combined.map"; |
||||
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_combined ULmapEUC_JIS_2004_combined[] = {\n"; |
||||
|
||||
for $index ( sort {$a cmp $b} keys( %array1 ) ){ |
||||
$code = $array1{ $index }; |
||||
$count1--; |
||||
if( $count1 == 0 ){ |
||||
printf FILE " {0x%s, 0x%s, 0x%06x} /* %s */\n", substr($index, 0, 8), substr($index, 8, 8), $code, $comment1{ $index }; |
||||
} else { |
||||
printf FILE " {0x%s, 0x%s, 0x%06x}, /* %s */\n", substr($index, 0, 8), substr($index, 8, 8), $code, $comment1{ $index }; |
||||
} |
||||
} |
||||
|
||||
print FILE "};\n"; |
||||
close(FILE); |
||||
|
||||
if ($TEST == 1) { |
||||
for $index ( sort {$a cmp $b} keys( %array1 ) ){ |
||||
$code = $array1{ $index }; |
||||
if ($code > 0x00 && $code != 0x09 && $code != 0x0a && $code != 0x0d && |
||||
$code != 0x5c && |
||||
($code < 0x80 || |
||||
($code >= 0x8ea1 && $code <= 0x8efe) || |
||||
($code >= 0x8fa1a1 && $code <= 0x8ffefe) || |
||||
($code >= 0xa1a1 && $code <= 0x8fefe))) { |
||||
|
||||
$v1 = hex(substr($index, 0, 8)); |
||||
$v2 = hex(substr($index, 8, 8)); |
||||
|
||||
for ($i = 3; $i >= 0; $i--) { |
||||
$s = $i * 8; |
||||
$mask = 0xff << $s; |
||||
print FILE1 pack("C", ($v1 & $mask) >> $s) if $v1 & $mask; |
||||
print FILE2 pack("C", ($code & $mask) >> $s) if $code & $mask; |
||||
} |
||||
for ($i = 3; $i >= 0; $i--) { |
||||
$s = $i * 8; |
||||
$mask = 0xff << $s; |
||||
print FILE1 pack("C", ($v2 & $mask) >> $s) if $v2 & $mask; |
||||
} |
||||
print FILE1 "\n"; |
||||
print FILE2 "\n"; |
||||
} |
||||
} |
||||
close(FILE1); |
||||
close(FILE2); |
||||
} |
||||
|
||||
# then generate EUC_JIS_2004 --> UTF-8 table |
||||
|
||||
$in_file = "euc-jis-2004-std.txt"; |
||||
|
||||
open( FILE, $in_file ) || die( "cannot open $in_file" ); |
||||
|
||||
reset 'array'; |
||||
reset 'array1'; |
||||
reset 'comment'; |
||||
reset 'comment1'; |
||||
|
||||
while($line = <FILE> ){ |
||||
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) { |
||||
$c = $1; |
||||
$u1 = $2; |
||||
$u2 = $3; |
||||
$rest = "U+" . $u1 . "+" . $u2 . $4; |
||||
$code = hex($c); |
||||
$ucs = hex($u1); |
||||
$utf1 = &ucs2utf($ucs); |
||||
$ucs = hex($u2); |
||||
$utf2 = &ucs2utf($ucs); |
||||
$str = sprintf "%08x%08x", $utf1, $utf2; |
||||
$array1{ $code } = $str; |
||||
$comment1{ $code } = $rest; |
||||
$count1++; |
||||
next; |
||||
} elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/) { |
||||
$c = $1; |
||||
$u = $2; |
||||
$rest = "U+" . $u . $3; |
||||
} else { |
||||
next; |
||||
} |
||||
|
||||
$ucs = hex($u); |
||||
$code = hex($c); |
||||
$utf = &ucs2utf($ucs); |
||||
if( $array{ $code } ne "" ){ |
||||
printf STDERR "Warning: duplicate UTF8: %04x\n",$ucs; |
||||
next; |
||||
} |
||||
$count++; |
||||
|
||||
$array{ $code } = $utf; |
||||
$comment{ $utf } = $rest; |
||||
} |
||||
close( FILE ); |
||||
|
||||
$file = "euc_jis_2004_to_utf8.map"; |
||||
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"; |
||||
|
||||
for $index ( sort {$a <=> $b} keys( %array ) ){ |
||||
$code = $array{ $index }; |
||||
$count--; |
||||
if( $count == 0 ){ |
||||
printf FILE " {0x%06x, 0x%08x} /* %s */\n", $index, $code, $comment{ $code }; |
||||
} else { |
||||
printf FILE " {0x%06x, 0x%08x}, /* %s */\n", $index, $code, $comment{ $code }; |
||||
} |
||||
} |
||||
|
||||
print FILE "};\n"; |
||||
close(FILE); |
||||
|
||||
$file = "euc_jis_2004_to_utf8_combined.map"; |
||||
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_combined LUmapEUC_JIS_2004_combined[] = {\n"; |
||||
|
||||
for $index ( sort {$a <=> $b} keys( %array1 ) ){ |
||||
$code = $array1{ $index }; |
||||
$count1--; |
||||
if( $count1 == 0 ){ |
||||
printf FILE " {0x%06x, 0x%s, 0x%s} /* %s */\n", $index, substr($code, 0, 8), substr($code, 8, 8), $comment1{ $index }; |
||||
} else { |
||||
printf FILE " {0x%06x, 0x%s, 0x%s}, /* %s */\n", $index, substr($code, 0, 8), substr($code, 8, 8), $comment1{ $index }; |
||||
} |
||||
} |
||||
|
||||
print FILE "};\n"; |
||||
close(FILE); |
@ -0,0 +1,189 @@ |
||||
#! /usr/bin/perl |
||||
# |
||||
# Copyright (c) 2007, PostgreSQL Global Development Group |
||||
# |
||||
# $PostgreSQL: pgsql/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl,v 1.1 2007/03/25 11:56:02 ishii Exp $ |
||||
# |
||||
# Generate UTF-8 <--> SHIFT_JIS_2004 code conversion tables from |
||||
# "sjis-0213-2004-std.txt" (http://x0213.org) |
||||
|
||||
require "ucs2utf.pl"; |
||||
|
||||
# first generate UTF-8 --> SHIFT_JIS_2004 table |
||||
|
||||
$in_file = "sjis-0213-2004-std.txt"; |
||||
|
||||
open( FILE, $in_file ) || die( "cannot open $in_file" ); |
||||
|
||||
reset 'array'; |
||||
reset 'array1'; |
||||
reset 'comment'; |
||||
reset 'comment1'; |
||||
|
||||
while($line = <FILE> ){ |
||||
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) { |
||||
$c = $1; |
||||
$u1 = $2; |
||||
$u2 = $3; |
||||
$rest = "U+" . $u1 . "+" . $u2 . $4; |
||||
$code = hex($c); |
||||
$ucs = hex($u1); |
||||
$utf1 = &ucs2utf($ucs); |
||||
$ucs = hex($u2); |
||||
$utf2 = &ucs2utf($ucs); |
||||
$str = sprintf "%08x%08x", $utf1, $utf2; |
||||
$array1{ $str } = $code; |
||||
$comment1{ $str } = $rest; |
||||
$count1++; |
||||
next; |
||||
} elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/) { |
||||
$c = $1; |
||||
$u = $2; |
||||
$rest = "U+" . $u . $3; |
||||
} else { |
||||
next; |
||||
} |
||||
|
||||
$ucs = hex($u); |
||||
$code = hex($c); |
||||
$utf = &ucs2utf($ucs); |
||||
if( $array{ $utf } ne "" ){ |
||||
printf STDERR "Warning: duplicate UTF8: %08x UCS: %04x Shift JIS: %04x\n",$utf, $ucs, $code; |
||||
next; |
||||
} |
||||
$count++; |
||||
|
||||
$array{ $utf } = $code; |
||||
$comment{ $code } = $rest; |
||||
} |
||||
close( FILE ); |
||||
|
||||
$file = "utf8_to_shift_jis_2004.map"; |
||||
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"; |
||||
|
||||
for $index ( sort {$a <=> $b} keys( %array ) ){ |
||||
$code = $array{ $index }; |
||||
$count--; |
||||
if( $count == 0 ){ |
||||
printf FILE " {0x%08x, 0x%06x} /* %s */\n", $index, $code, $comment{ $code }; |
||||
} else { |
||||
printf FILE " {0x%08x, 0x%06x}, /* %s */\n", $index, $code, $comment{ $code }; |
||||
} |
||||
} |
||||
|
||||
print FILE "};\n"; |
||||
close(FILE); |
||||
|
||||
$file = "utf8_to_shift_jis_2004_combined.map"; |
||||
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_combined ULmapSHIFT_JIS_2004_combined[] = {\n"; |
||||
|
||||
for $index ( sort {$a cmp $b} keys( %array1 ) ){ |
||||
$code = $array1{ $index }; |
||||
$count1--; |
||||
if( $count1 == 0 ){ |
||||
printf FILE " {0x%s, 0x%s, 0x%04x} /* %s */\n", substr($index, 0, 8), substr($index, 8, 8), $code, $comment1{ $index }; |
||||
} else { |
||||
printf FILE " {0x%s, 0x%s, 0x%04x}, /* %s */\n", substr($index, 0, 8), substr($index, 8, 8), $code, $comment1{ $index }; |
||||
} |
||||
} |
||||
|
||||
print FILE "};\n"; |
||||
close(FILE); |
||||
|
||||
# then generate SHIFT_JIS_2004 --> UTF-8 table |
||||
|
||||
$in_file = "sjis-0213-2004-std.txt"; |
||||
|
||||
open( FILE, $in_file ) || die( "cannot open $in_file" ); |
||||
|
||||
reset 'array'; |
||||
reset 'array1'; |
||||
reset 'comment'; |
||||
reset 'comment1'; |
||||
|
||||
while($line = <FILE> ){ |
||||
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/) { |
||||
$c = $1; |
||||
$u1 = $2; |
||||
$u2 = $3; |
||||
$rest = "U+" . $u1 . "+" . $u2 . $4; |
||||
$code = hex($c); |
||||
$ucs = hex($u1); |
||||
$utf1 = &ucs2utf($ucs); |
||||
$ucs = hex($u2); |
||||
$utf2 = &ucs2utf($ucs); |
||||
$str = sprintf "%08x%08x", $utf1, $utf2; |
||||
$array1{ $code } = $str; |
||||
$comment1{ $code } = $rest; |
||||
$count1++; |
||||
next; |
||||
} elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/) { |
||||
$c = $1; |
||||
$u = $2; |
||||
$rest = "U+" . $u . $3; |
||||
} else { |
||||
next; |
||||
} |
||||
|
||||
$ucs = hex($u); |
||||
$code = hex($c); |
||||
$utf = &ucs2utf($ucs); |
||||
if( $array{ $code } ne "" ){ |
||||
printf STDERR "Warning: duplicate UTF-8: %08x UCS: %04x Shift JIS: %04x\n",$utf, $ucs, $code; |
||||
printf STDERR "Previous value: UTF-8: %08x\n", $array{ $utf }; |
||||
next; |
||||
} |
||||
$count++; |
||||
|
||||
$array{ $code } = $utf; |
||||
$comment{ $utf } = $rest; |
||||
} |
||||
close( FILE ); |
||||
|
||||
$file = "shift_jis_2004_to_utf8.map"; |
||||
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"; |
||||
|
||||
for $index ( sort {$a <=> $b} keys( %array ) ){ |
||||
$code = $array{ $index }; |
||||
$count--; |
||||
if( $count == 0 ){ |
||||
printf FILE " {0x%04x, 0x%08x} /* %s */\n", $index, $code, $comment{ $code }; |
||||
} else { |
||||
printf FILE " {0x%04x, 0x%08x}, /* %s */\n", $index, $code, $comment{ $code }; |
||||
} |
||||
} |
||||
|
||||
print FILE "};\n"; |
||||
close(FILE); |
||||
|
||||
$file = "shift_jis_2004_to_utf8_combined.map"; |
||||
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_local_to_utf_combined LUmapSHIFT_JIS_2004_combined[] = {\n"; |
||||
|
||||
for $index ( sort {$a <=> $b} keys( %array1 ) ){ |
||||
$code = $array1{ $index }; |
||||
$count1--; |
||||
if( $count1 == 0 ){ |
||||
printf FILE " {0x%04x, 0x%s, 0x%s} /* %s */\n", $index, substr($code, 0, 8), substr($code, 8, 8), $comment1{ $index }; |
||||
} else { |
||||
printf FILE " {0x%04x, 0x%s, 0x%s}, /* %s */\n", $index, substr($code, 0, 8), substr($code, 8, 8), $comment1{ $index }; |
||||
} |
||||
} |
||||
|
||||
print FILE "};\n"; |
||||
close(FILE); |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,30 @@ |
||||
/* |
||||
* This file was generated by UCS_to_EUC_JIS_2004.pl |
||||
*/ |
||||
static 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] */ |
||||
{0x00a4fa, 0x00e38191, 0x00e3829a}, /* U+3051+309A [2000] */ |
||||
{0x00a4fb, 0x00e38193, 0x00e3829a}, /* U+3053+309A [2000] */ |
||||
{0x00a5f7, 0x00e382ab, 0x00e3829a}, /* U+30AB+309A [2000] */ |
||||
{0x00a5f8, 0x00e382ad, 0x00e3829a}, /* U+30AD+309A [2000] */ |
||||
{0x00a5f9, 0x00e382af, 0x00e3829a}, /* U+30AF+309A [2000] */ |
||||
{0x00a5fa, 0x00e382b1, 0x00e3829a}, /* U+30B1+309A [2000] */ |
||||
{0x00a5fb, 0x00e382b3, 0x00e3829a}, /* U+30B3+309A [2000] */ |
||||
{0x00a5fc, 0x00e382bb, 0x00e3829a}, /* U+30BB+309A [2000] */ |
||||
{0x00a5fd, 0x00e38384, 0x00e3829a}, /* U+30C4+309A [2000] */ |
||||
{0x00a5fe, 0x00e38388, 0x00e3829a}, /* U+30C8+309A [2000] */ |
||||
{0x00a6f8, 0x00e387b7, 0x00e3829a}, /* U+31F7+309A [2000] */ |
||||
{0x00abc4, 0x0000c3a6, 0x0000cc80}, /* U+00E6+0300 [2000] */ |
||||
{0x00abc8, 0x0000c994, 0x0000cc80}, /* U+0254+0300 [2000] */ |
||||
{0x00abc9, 0x0000c994, 0x0000cc81}, /* U+0254+0301 [2000] */ |
||||
{0x00abca, 0x0000ca8c, 0x0000cc80}, /* U+028C+0300 [2000] */ |
||||
{0x00abcb, 0x0000ca8c, 0x0000cc81}, /* U+028C+0301 [2000] */ |
||||
{0x00abcc, 0x0000c999, 0x0000cc80}, /* U+0259+0300 [2000] */ |
||||
{0x00abcd, 0x0000c999, 0x0000cc81}, /* U+0259+0301 [2000] */ |
||||
{0x00abce, 0x0000c99a, 0x0000cc80}, /* U+025A+0300 [2000] */ |
||||
{0x00abcf, 0x0000c99a, 0x0000cc81}, /* U+025A+0301 [2000] */ |
||||
{0x00abe5, 0x0000cba9, 0x0000cba5}, /* U+02E9+02E5 [2000] */ |
||||
{0x00abe6, 0x0000cba5, 0x0000cba9} /* U+02E5+02E9 [2000] */ |
||||
}; |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,30 @@ |
||||
/* |
||||
* This file was generated by UCS_to_SHIFT_JIS_2004.pl |
||||
*/ |
||||
static 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] */ |
||||
{0x82f8, 0x00e38191, 0x00e3829a}, /* U+3051+309A [2000] */ |
||||
{0x82f9, 0x00e38193, 0x00e3829a}, /* U+3053+309A [2000] */ |
||||
{0x8397, 0x00e382ab, 0x00e3829a}, /* U+30AB+309A [2000] */ |
||||
{0x8398, 0x00e382ad, 0x00e3829a}, /* U+30AD+309A [2000] */ |
||||
{0x8399, 0x00e382af, 0x00e3829a}, /* U+30AF+309A [2000] */ |
||||
{0x839a, 0x00e382b1, 0x00e3829a}, /* U+30B1+309A [2000] */ |
||||
{0x839b, 0x00e382b3, 0x00e3829a}, /* U+30B3+309A [2000] */ |
||||
{0x839c, 0x00e382bb, 0x00e3829a}, /* U+30BB+309A [2000] */ |
||||
{0x839d, 0x00e38384, 0x00e3829a}, /* U+30C4+309A [2000] */ |
||||
{0x839e, 0x00e38388, 0x00e3829a}, /* U+30C8+309A [2000] */ |
||||
{0x83f6, 0x00e387b7, 0x00e3829a}, /* U+31F7+309A [2000] */ |
||||
{0x8663, 0x0000c3a6, 0x0000cc80}, /* U+00E6+0300 [2000] */ |
||||
{0x8667, 0x0000c994, 0x0000cc80}, /* U+0254+0300 [2000] */ |
||||
{0x8668, 0x0000c994, 0x0000cc81}, /* U+0254+0301 [2000] */ |
||||
{0x8669, 0x0000ca8c, 0x0000cc80}, /* U+028C+0300 [2000] */ |
||||
{0x866a, 0x0000ca8c, 0x0000cc81}, /* U+028C+0301 [2000] */ |
||||
{0x866b, 0x0000c999, 0x0000cc80}, /* U+0259+0300 [2000] */ |
||||
{0x866c, 0x0000c999, 0x0000cc81}, /* U+0259+0301 [2000] */ |
||||
{0x866d, 0x0000c99a, 0x0000cc80}, /* U+025A+0300 [2000] */ |
||||
{0x866e, 0x0000c99a, 0x0000cc81}, /* U+025A+0301 [2000] */ |
||||
{0x8685, 0x0000cba9, 0x0000cba5}, /* U+02E9+02E5 [2000] */ |
||||
{0x8686, 0x0000cba5, 0x0000cba9} /* U+02E5+02E9 [2000] */ |
||||
}; |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,30 @@ |
||||
/* |
||||
* This file was generated by UCS_to_EUC_JIS_2004.pl |
||||
*/ |
||||
static 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] */ |
||||
{0x0000c999, 0x0000cc80, 0x00abcc}, /* U+0259+0300 [2000] */ |
||||
{0x0000c999, 0x0000cc81, 0x00abcd}, /* U+0259+0301 [2000] */ |
||||
{0x0000c99a, 0x0000cc80, 0x00abce}, /* U+025A+0300 [2000] */ |
||||
{0x0000c99a, 0x0000cc81, 0x00abcf}, /* U+025A+0301 [2000] */ |
||||
{0x0000ca8c, 0x0000cc80, 0x00abca}, /* U+028C+0300 [2000] */ |
||||
{0x0000ca8c, 0x0000cc81, 0x00abcb}, /* U+028C+0301 [2000] */ |
||||
{0x0000cba5, 0x0000cba9, 0x00abe6}, /* U+02E5+02E9 [2000] */ |
||||
{0x0000cba9, 0x0000cba5, 0x00abe5}, /* U+02E9+02E5 [2000] */ |
||||
{0x00e3818b, 0x00e3829a, 0x00a4f7}, /* U+304B+309A [2000] */ |
||||
{0x00e3818d, 0x00e3829a, 0x00a4f8}, /* U+304D+309A [2000] */ |
||||
{0x00e3818f, 0x00e3829a, 0x00a4f9}, /* U+304F+309A [2000] */ |
||||
{0x00e38191, 0x00e3829a, 0x00a4fa}, /* U+3051+309A [2000] */ |
||||
{0x00e38193, 0x00e3829a, 0x00a4fb}, /* U+3053+309A [2000] */ |
||||
{0x00e382ab, 0x00e3829a, 0x00a5f7}, /* U+30AB+309A [2000] */ |
||||
{0x00e382ad, 0x00e3829a, 0x00a5f8}, /* U+30AD+309A [2000] */ |
||||
{0x00e382af, 0x00e3829a, 0x00a5f9}, /* U+30AF+309A [2000] */ |
||||
{0x00e382b1, 0x00e3829a, 0x00a5fa}, /* U+30B1+309A [2000] */ |
||||
{0x00e382b3, 0x00e3829a, 0x00a5fb}, /* U+30B3+309A [2000] */ |
||||
{0x00e382bb, 0x00e3829a, 0x00a5fc}, /* U+30BB+309A [2000] */ |
||||
{0x00e38384, 0x00e3829a, 0x00a5fd}, /* U+30C4+309A [2000] */ |
||||
{0x00e38388, 0x00e3829a, 0x00a5fe}, /* U+30C8+309A [2000] */ |
||||
{0x00e387b7, 0x00e3829a, 0x00a6f8} /* U+31F7+309A [2000] */ |
||||
}; |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,30 @@ |
||||
/* |
||||
* This file was generated by UCS_to_SHIFT_JIS_2004.pl |
||||
*/ |
||||
static 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] */ |
||||
{0x0000c999, 0x0000cc80, 0x866b}, /* U+0259+0300 [2000] */ |
||||
{0x0000c999, 0x0000cc81, 0x866c}, /* U+0259+0301 [2000] */ |
||||
{0x0000c99a, 0x0000cc80, 0x866d}, /* U+025A+0300 [2000] */ |
||||
{0x0000c99a, 0x0000cc81, 0x866e}, /* U+025A+0301 [2000] */ |
||||
{0x0000ca8c, 0x0000cc80, 0x8669}, /* U+028C+0300 [2000] */ |
||||
{0x0000ca8c, 0x0000cc81, 0x866a}, /* U+028C+0301 [2000] */ |
||||
{0x0000cba5, 0x0000cba9, 0x8686}, /* U+02E5+02E9 [2000] */ |
||||
{0x0000cba9, 0x0000cba5, 0x8685}, /* U+02E9+02E5 [2000] */ |
||||
{0x00e3818b, 0x00e3829a, 0x82f5}, /* U+304B+309A [2000] */ |
||||
{0x00e3818d, 0x00e3829a, 0x82f6}, /* U+304D+309A [2000] */ |
||||
{0x00e3818f, 0x00e3829a, 0x82f7}, /* U+304F+309A [2000] */ |
||||
{0x00e38191, 0x00e3829a, 0x82f8}, /* U+3051+309A [2000] */ |
||||
{0x00e38193, 0x00e3829a, 0x82f9}, /* U+3053+309A [2000] */ |
||||
{0x00e382ab, 0x00e3829a, 0x8397}, /* U+30AB+309A [2000] */ |
||||
{0x00e382ad, 0x00e3829a, 0x8398}, /* U+30AD+309A [2000] */ |
||||
{0x00e382af, 0x00e3829a, 0x8399}, /* U+30AF+309A [2000] */ |
||||
{0x00e382b1, 0x00e3829a, 0x839a}, /* U+30B1+309A [2000] */ |
||||
{0x00e382b3, 0x00e3829a, 0x839b}, /* U+30B3+309A [2000] */ |
||||
{0x00e382bb, 0x00e3829a, 0x839c}, /* U+30BB+309A [2000] */ |
||||
{0x00e38384, 0x00e3829a, 0x839d}, /* U+30C4+309A [2000] */ |
||||
{0x00e38388, 0x00e3829a, 0x839e}, /* U+30C8+309A [2000] */ |
||||
{0x00e387b7, 0x00e3829a, 0x83f6} /* U+31F7+309A [2000] */ |
||||
}; |
@ -0,0 +1,12 @@ |
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jis_2004_and_shift_jis_2004/Makefile,v 1.1 2007/03/25 11:56:02 ishii Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
subdir = src/backend/utils/mb/conversion_procs/euc_jis_2004_and_shit_jis_2004
|
||||
top_builddir = ../../../../../..
|
||||
include $(top_builddir)/src/Makefile.global |
||||
|
||||
NAME = euc_jis_2004_and_shift_jis_2004
|
||||
|
||||
include $(srcdir)/../proc.mk |
@ -0,0 +1,333 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* EUC_JIS_2004, SHIFT_JIS_2004 |
||||
* |
||||
* Copyright (c) 2007, PostgreSQL Global Development Group |
||||
* |
||||
* IDENTIFICATION |
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jis_2004_and_shift_jis_2004/euc_jis_2004_and_shift_jis_2004.c,v 1.1 2007/03/25 11:56:02 ishii Exp $ |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
|
||||
#include "postgres.h" |
||||
#include "fmgr.h" |
||||
#include "mb/pg_wchar.h" |
||||
|
||||
PG_MODULE_MAGIC; |
||||
|
||||
PG_FUNCTION_INFO_V1(euc_jis_2004_to_shift_jis_2004); |
||||
PG_FUNCTION_INFO_V1(shift_jis_2004_to_euc_jis_2004); |
||||
|
||||
extern Datum euc_jis_2004_to_shift_jis_2004(PG_FUNCTION_ARGS); |
||||
extern Datum shift_jis_2004_to_euc_jis_2004(PG_FUNCTION_ARGS); |
||||
|
||||
static void euc_jis_20042shift_jis_2004(const unsigned char *euc, unsigned char *p, int len); |
||||
static void shift_jis_20042euc_jis_2004(const unsigned char *sjis, unsigned char *p, int len); |
||||
|
||||
/* ----------
|
||||
* conv_proc( |
||||
* INTEGER, -- source encoding id |
||||
* INTEGER, -- destination encoding id |
||||
* CSTRING, -- source string (null terminated C string) |
||||
* CSTRING, -- destination string (null terminated C string) |
||||
* INTEGER -- source string length |
||||
* ) returns VOID; |
||||
* ---------- |
||||
*/ |
||||
|
||||
Datum |
||||
euc_jis_2004_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); |
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_JIS_2004); |
||||
Assert(PG_GETARG_INT32(1) == PG_SHIFT_JIS_2004); |
||||
Assert(len >= 0); |
||||
|
||||
euc_jis_20042shift_jis_2004(src, dest, len); |
||||
|
||||
PG_RETURN_VOID(); |
||||
} |
||||
|
||||
Datum |
||||
shift_jis_2004_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); |
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_SHIFT_JIS_2004); |
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_JIS_2004); |
||||
Assert(len >= 0); |
||||
|
||||
shift_jis_20042euc_jis_2004(src, dest, len); |
||||
|
||||
PG_RETURN_VOID(); |
||||
} |
||||
|
||||
/*
|
||||
* EUC_JIS_2004 -> SHIFT_JIS_2004 |
||||
*/ |
||||
static void |
||||
euc_jis_20042shift_jis_2004(const unsigned char *euc, unsigned char *p, int len) |
||||
{ |
||||
int c1, |
||||
ku, |
||||
ten; |
||||
int l; |
||||
|
||||
while (len > 0) |
||||
{ |
||||
c1 = *euc; |
||||
if (!IS_HIGHBIT_SET(c1)) |
||||
{ |
||||
/* ASCII */ |
||||
if (c1 == 0) |
||||
report_invalid_encoding(PG_EUC_JIS_2004, |
||||
(const char *) euc, len); |
||||
*p++ = c1; |
||||
euc++; |
||||
len--; |
||||
continue; |
||||
} |
||||
|
||||
l = pg_encoding_verifymb(PG_EUC_JIS_2004, (const char *) euc, len); |
||||
|
||||
if (l < 0) |
||||
report_invalid_encoding(PG_EUC_JIS_2004, |
||||
(const char *) euc, len); |
||||
|
||||
if (c1 == SS2 && l == 2) /* JIS X 0201 kana? */ |
||||
{ |
||||
*p++ = euc[1]; |
||||
} |
||||
else if (c1 == SS3 && l == 3) /* JIS X 0213 plane 2? */ |
||||
{ |
||||
ku = euc[1] - 0xa0; |
||||
ten = euc[2] - 0xa0; |
||||
|
||||
switch (ku) |
||||
{ |
||||
case 1: |
||||
case 3: |
||||
case 4: |
||||
case 5: |
||||
case 8: |
||||
case 12: |
||||
case 13: |
||||
case 14: |
||||
case 15: |
||||
*p++ = ((ku + 0x1df) >> 1) - (ku >> 3) * 3; |
||||
break; |
||||
default: |
||||
if (ku >= 78 && ku <= 94) |
||||
{ |
||||
*p++ = (ku + 0x19b) >> 1; |
||||
} |
||||
else |
||||
report_invalid_encoding(PG_EUC_JIS_2004, |
||||
(const char *) euc, len); |
||||
} |
||||
|
||||
if (ku % 2) |
||||
{ |
||||
if (ten >= 1 && ten <= 63) |
||||
*p++ = ten + 0x3f; |
||||
else if (ten >= 64 && ten <= 94) |
||||
*p++ = ten + 0x40; |
||||
else |
||||
report_invalid_encoding(PG_EUC_JIS_2004, |
||||
(const char *) euc, len); |
||||
} |
||||
else |
||||
*p++ = ten + 0x9e; |
||||
} |
||||
|
||||
else if (l == 2) /* JIS X 0213 plane 1? */ |
||||
{ |
||||
ku = c1 - 0xa0; |
||||
ten = euc[1] - 0xa0; |
||||
|
||||
if (ku >= 1 && ku <= 62) |
||||
*p++ = (ku + 0x101) >> 1; |
||||
else if (ku >= 63 && ku <= 94) |
||||
*p++ = (ku + 0x181) >> 1; |
||||
else |
||||
report_invalid_encoding(PG_EUC_JIS_2004, |
||||
(const char *) euc, len); |
||||
|
||||
if (ku % 2) |
||||
{ |
||||
if (ten >= 1 && ten <= 63) |
||||
*p++ = ten + 0x3f; |
||||
else if (ten >= 64 && ten <= 94) |
||||
*p++ = ten + 0x40; |
||||
else |
||||
report_invalid_encoding(PG_EUC_JIS_2004, |
||||
(const char *) euc, len); |
||||
} |
||||
else |
||||
*p++ = ten + 0x9e; |
||||
} |
||||
else |
||||
report_invalid_encoding(PG_EUC_JIS_2004, |
||||
(const char *) euc, len); |
||||
|
||||
euc += l; |
||||
len -= l; |
||||
} |
||||
*p = '\0'; |
||||
} |
||||
|
||||
/*
|
||||
* returns SHIFT_JIS_2004 "ku" code indicated by second byte |
||||
* *ku = 0: "ku" = even |
||||
* *ku = 1: "ku" = odd |
||||
*/ |
||||
static int get_ten(int b, int *ku) |
||||
{ |
||||
int ten; |
||||
|
||||
if (b >= 0x40 && b <= 0x7e) |
||||
{ |
||||
ten = b - 0x3f; |
||||
*ku = 1; |
||||
} else if (b >= 0x80 && b <= 0x9e) |
||||
{ |
||||
ten = b - 0x40; |
||||
*ku = 1; |
||||
} else if (b >= 0x9f && b <= 0xfc) |
||||
{ |
||||
ten = b - 0x9e; |
||||
*ku = 0; |
||||
} |
||||
else |
||||
{ |
||||
ten = -1; /* error */ |
||||
} |
||||
return ten; |
||||
} |
||||
|
||||
/*
|
||||
* SHIFT_JIS_2004 ---> EUC_JIS_2004 |
||||
*/ |
||||
|
||||
static void |
||||
shift_jis_20042euc_jis_2004(const unsigned char *sjis, unsigned char *p, int len) |
||||
{ |
||||
int c1, |
||||
c2; |
||||
int ku, ten, kubun; |
||||
int plane; |
||||
int l; |
||||
|
||||
while (len > 0) |
||||
{ |
||||
c1 = *sjis; |
||||
c2 = sjis[1]; |
||||
|
||||
if (!IS_HIGHBIT_SET(c1)) |
||||
{ |
||||
/* ASCII */ |
||||
if (c1 == 0) |
||||
report_invalid_encoding(PG_SHIFT_JIS_2004, |
||||
(const char *) sjis, len); |
||||
*p++ = c1; |
||||
sjis++; |
||||
len--; |
||||
continue; |
||||
} |
||||
|
||||
l = pg_encoding_verifymb(PG_SHIFT_JIS_2004, (const char *) sjis, len); |
||||
|
||||
if (l < 0) |
||||
report_invalid_encoding(PG_SHIFT_JIS_2004, |
||||
(const char *) sjis, len); |
||||
|
||||
if (c1 >= 0xa1 && c1 <= 0xdf && l == 1) |
||||
{ |
||||
/* JIS X0201 (1 byte kana) */ |
||||
*p++ = SS2; |
||||
*p++ = c1; |
||||
} |
||||
else if (l == 2) |
||||
{ |
||||
plane = 1; |
||||
ku = 1; |
||||
ten = 1; |
||||
|
||||
/*
|
||||
* JIS X 0213 |
||||
*/ |
||||
if (c1 >= 0x81 && c1 <= 0x9f) /* plane 1 1ku-62ku */ |
||||
{ |
||||
ku = (c1 << 1) - 0x100; |
||||
ten = get_ten(c2, &kubun); |
||||
if (ten < 0) |
||||
report_invalid_encoding(PG_SHIFT_JIS_2004, |
||||
(const char *) sjis, len); |
||||
ku -= kubun; |
||||
} |
||||
else if (c1 >= 0xe0 && c1 <= 0xef) /* plane 1 62ku-94ku */ |
||||
{ |
||||
ku = (c1 << 1) - 0x180; |
||||
ten = get_ten(c2, &kubun); |
||||
if (ten < 0) |
||||
report_invalid_encoding(PG_SHIFT_JIS_2004, |
||||
|
||||
(const char *) sjis, len); |
||||
ku -= kubun; |
||||
} |
||||
else if (c1 >= 0xf0 && c1 <= 0xf3) /* plane 2 1,3,4,5,8,12,13,14,15 ku */ |
||||
{ |
||||
plane = 2; |
||||
ten = get_ten(c2, &kubun); |
||||
if (ten < 0) |
||||
report_invalid_encoding(PG_SHIFT_JIS_2004, |
||||
(const char *) sjis, len); |
||||
switch (c1) |
||||
{ |
||||
case 0xf0: |
||||
ku = kubun == 0? 8: 1;
|
||||
break; |
||||
case 0xf1: |
||||
ku = kubun == 0? 4: 3; |
||||
break; |
||||
case 0xf2: |
||||
ku = kubun == 0? 12: 5; |
||||
break; |
||||
default: |
||||
ku = kubun == 0? 14: 13; |
||||
break; |
||||
} |
||||
} |
||||
else if (c1 >= 0xf4 && c1 <= 0xfc) /* plane 2 78-94ku */ |
||||
{ |
||||
plane = 2; |
||||
ten = get_ten(c2, &kubun); |
||||
if (ten < 0) |
||||
report_invalid_encoding(PG_SHIFT_JIS_2004, |
||||
(const char *) sjis, len); |
||||
if (c1 == 0xf4 && kubun == 1) |
||||
ku = 15; |
||||
else |
||||
ku = (c1 << 1) - 0x19a - kubun; |
||||
} |
||||
else |
||||
report_invalid_encoding(PG_SHIFT_JIS_2004, |
||||
(const char *) sjis, len); |
||||
|
||||
if (plane == 2) |
||||
*p++ = SS3; |
||||
|
||||
*p++ = ku + 0xa0; |
||||
*p++ = ten + 0xa0; |
||||
} |
||||
sjis += l; |
||||
len -= l; |
||||
} |
||||
*p = '\0'; |
||||
} |
@ -0,0 +1,12 @@ |
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jis_2004/Makefile,v 1.1 2007/03/25 11:56:02 ishii Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
subdir = src/backend/utils/mb/conversion_procs/utf8_and_euc_jis_2004
|
||||
top_builddir = ../../../../../..
|
||||
include $(top_builddir)/src/Makefile.global |
||||
|
||||
NAME = utf8_and_euc_jis_2004
|
||||
|
||||
include $(srcdir)/../proc.mk |
@ -0,0 +1,76 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* EUC_JIS_2004 <--> UTF8 |
||||
* |
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* IDENTIFICATION |
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jis_2004/utf8_and_euc_jis_2004.c,v 1.1 2007/03/25 11:56:03 ishii Exp $ |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
|
||||
#include "postgres.h" |
||||
#include "fmgr.h" |
||||
#include "mb/pg_wchar.h" |
||||
#include "../../Unicode/euc_jis_2004_to_utf8.map" |
||||
#include "../../Unicode/utf8_to_euc_jis_2004.map" |
||||
#include "../../Unicode/euc_jis_2004_to_utf8_combined.map" |
||||
#include "../../Unicode/utf8_to_euc_jis_2004_combined.map" |
||||
|
||||
PG_MODULE_MAGIC; |
||||
|
||||
PG_FUNCTION_INFO_V1(euc_jis_2004_to_utf8); |
||||
PG_FUNCTION_INFO_V1(utf8_to_euc_jis_2004); |
||||
|
||||
extern Datum euc_jis_2004_to_utf8(PG_FUNCTION_ARGS); |
||||
extern Datum utf8_to_euc_jis_2004(PG_FUNCTION_ARGS); |
||||
|
||||
/* ----------
|
||||
* conv_proc( |
||||
* INTEGER, -- source encoding id |
||||
* INTEGER, -- destination encoding id |
||||
* CSTRING, -- source string (null terminated C string) |
||||
* CSTRING, -- destination string (null terminated C string) |
||||
* INTEGER -- source string length |
||||
* ) returns VOID; |
||||
* ---------- |
||||
*/ |
||||
Datum |
||||
euc_jis_2004_to_utf8(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_EUC_JIS_2004); |
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8); |
||||
Assert(len >= 0); |
||||
|
||||
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); |
||||
|
||||
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); |
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8); |
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_JIS_2004); |
||||
Assert(len >= 0); |
||||
|
||||
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); |
||||
|
||||
PG_RETURN_VOID(); |
||||
} |
@ -0,0 +1,12 @@ |
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_shift_jis_2004/Makefile,v 1.1 2007/03/25 11:56:03 ishii Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
subdir = src/backend/utils/mb/conversion_procs/utf8_and_shift_jis_2004
|
||||
top_builddir = ../../../../../..
|
||||
include $(top_builddir)/src/Makefile.global |
||||
|
||||
NAME = utf8_and_shift_jis_2004
|
||||
|
||||
include $(srcdir)/../proc.mk |
@ -0,0 +1,76 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* SHIFT_JIS_2004 <--> UTF8 |
||||
* |
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* IDENTIFICATION |
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_shift_jis_2004/utf8_and_shift_jis_2004.c,v 1.1 2007/03/25 11:56:03 ishii Exp $ |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
|
||||
#include "postgres.h" |
||||
#include "fmgr.h" |
||||
#include "mb/pg_wchar.h" |
||||
#include "../../Unicode/shift_jis_2004_to_utf8.map" |
||||
#include "../../Unicode/utf8_to_shift_jis_2004.map" |
||||
#include "../../Unicode/shift_jis_2004_to_utf8_combined.map" |
||||
#include "../../Unicode/utf8_to_shift_jis_2004_combined.map" |
||||
|
||||
PG_MODULE_MAGIC; |
||||
|
||||
PG_FUNCTION_INFO_V1(shift_jis_2004_to_utf8); |
||||
PG_FUNCTION_INFO_V1(utf8_to_shift_jis_2004); |
||||
|
||||
extern Datum shift_jis_2004_to_utf8(PG_FUNCTION_ARGS); |
||||
extern Datum utf8_to_shift_jis_2004(PG_FUNCTION_ARGS); |
||||
|
||||
/* ----------
|
||||
* conv_proc( |
||||
* INTEGER, -- source encoding id |
||||
* INTEGER, -- destination encoding id |
||||
* CSTRING, -- source string (null terminated C string) |
||||
* CSTRING, -- destination string (null terminated C string) |
||||
* INTEGER -- source string length |
||||
* ) returns VOID; |
||||
* ---------- |
||||
*/ |
||||
Datum |
||||
shift_jis_2004_to_utf8(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_SHIFT_JIS_2004); |
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8); |
||||
Assert(len >= 0); |
||||
|
||||
LocalToUtf(src, dest, LUmapSHIFT_JIS_2004, LUmapSHIFT_JIS_2004_combined, |
||||
sizeof(LUmapSHIFT_JIS_2004) / sizeof(pg_local_to_utf), |
||||
sizeof(LUmapSHIFT_JIS_2004_combined) / sizeof(pg_local_to_utf_combined), |
||||
PG_SHIFT_JIS_2004, 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); |
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8); |
||||
Assert(PG_GETARG_INT32(1) == PG_SHIFT_JIS_2004); |
||||
Assert(len >= 0); |
||||
|
||||
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(); |
||||
} |
Loading…
Reference in new issue