Gossamer Forum
Home : Products : DBMan : Installation :

How do you incorporate (jcode.pl)

Quote Reply
How do you incorporate (jcode.pl)
Okay, I've seen a post related to using Chinese or Japanese characters in dbman but there is a libarary called -- jcode.pl. I'm wondering How do I use this libarary to 1.) show Japanese characters within my forms and output screens and 2.) how to use Japanese characters to input data. I'm searching into this myself but I'M NOT a perl programmer and most of it looks "Japanese to me". Frown Of course I can read the Japanese characters.
Or is there a cheating method of just changing the headers to include the "x-jis" coding using metatags?
Netscape allows you to view the character coding but DBMan spits out gibberish eventhough I edited the html.pl to show the characters. Can anybody help me?

------------------
Thanks for everything !
Quote Reply
Re: How do you incorporate (jcode.pl) In reply to
Okay I found this on the net.


require 'jcode.pl';

sub read_input
{
local ($buffer, @pairs, $pair, $name, $value, %FORM);
# Read in text
$ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
if ($ENV{'REQUEST_METHOD'} eq "POST")
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else
{
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
&jcode'convert(*value, 'euc');
$FORM{$name} = $value;
}
%FORM;
}

and from a CGI that is used for a BBS system:

### --- フォームからのデータ処理 (from form decoding management)--- ###
sub form_deco {
if ($ENV{'REQUEST_METHOD'} eq "POST") {
if ($ENV{'CONTENT_LENGTH'} > 51200) { &error("投稿量が大きすぎます。data is too large"); }
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else { $buffer = $ENV{'QUERY_STRING'}; }

@pairs = split(/&/,$buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

# 文字コード変換 (convert japanese characters)
&jcode'convert(*value,'sjis');

# タグ処理 (tag management)
if ($tagkey == 0) {
$value =~ s/</\&lt\;/g;
$value =~ s/>/\&gt\;/g;
$value =~ s/\"/\&quot\;/g;
} else {
$value =~ s/<>/\&lt\;\&gt\;/g;
}
$FORM{$name} = $value;
}
$name = $FORM{'name'};
$comment = $FORM{'comment'};
$comment =~ s/\r\n/<br>/g;
$comment =~ s/\r|\n/<br>/g;
$email = $FORM{'email'};
$url = $FORM{'url'};
$url =~ s/^http\:\/\///;
$mode = $FORM{'mode'};
$pwd = $FORM{'pwd'};
$subj = $FORM{'subj'};
$usr_pwd = $FORM{'usr_pwd'};
$usrid = $FORM{'usrid'};
$inpwd = $FORM{'inpwd'};

# 日時の取得 (time calculations)
$ENV{'TZ'} = "JST-9";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
if ($year < 10) { $year = "0$year"; }
$mon++;
if ($mon < 10) { $mon = "0$mon"; }
if ($mday < 10) { $mday = "0$mday"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($min < 10) { $min = "0$min"; }
$date = "$year/$mon/$mday\-$hour:$min"; # 日時のフォーマット (day,date formats)
}

I translated the Japanese comments or output in case it turns to gibberish on your screen.
I really wish I knew what was happening in all of this. I get the basic idea but there are so many backslashes and other programming thing-a-ma-bobs that I just have no clue.
Is there any help for me or Is this just a lost cause?