--- html/vizitka.cgi 2000/05/24 17:38:45 1.1
+++ html/vizitka.cgi 2000/05/24 17:39:36 1.2
@@ -20,8 +20,25 @@
'sn'=>'prezime',
'cn'=>'ime i prezime');
+%utf2iso_tab = (
+0x0161 => 'š', 0x0111 => 'đ', 0x010d => 'č', 0x0107 => 'ć', 0x017e => 'ž',
+0x0160 => 'Š', 0x0110 => 'Đ', 0x010c => 'Č', 0x0106 => 'Ć', 0x017d => 'Ž'
+);
-print header(-type => 'text/html;charset=UTF-8'),
+sub utf2iso {
+ my $out;
+ foreach (@_) {
+ s/([\xC0-\xDF])([\x80-\xBF])/$utf2iso_tab{unpack("c",$1)<<6&0x07C0|unpack("c",$2)&0x003F}/ge;
+ s/([\xE0-\xEF])([\x80-\xBF])([\x80-\xBF])/$utf2iso_tab{unpack("c",$1)<<12&0xF000|unpack("c",$2)<<6&0x0FC0|unpack("c",$3)&0x003F}/ge;
+ s/([\xF0-\xF7])([\x80-\xBF])([\x80-\xBF])([\x80-\xBF])/$utf2iso_tab{unpack("c",$1)<<18&0x1C0000|unpack("c",$2)<<12&0x3F000|unpack("c",$3)<<6&0x0FC0|unpack("c",$4)&0x003F}/ge;
+ $out.=$_;
+ }
+ return $out;
+}
+
+print
+# header(-type => 'text/html;charset=UTF-8'),
+ header,
start_html('Naručivanje vizitki'),
start_form,
"Upišite svoje ",popup_menu(-name=>'what',
@@ -51,7 +68,7 @@
for($i = 0 ; $i < $max ; $i++) {
my $entry = $mesg->entry($i);
my ($mail) = $entry->get('mail'); # array, take first
- my ($cn)=$entry->get('cn');
+ my ($cn)=utf2iso($entry->get('cn'));
push @radio_vals,$cn;
$radio_labels{$cn}=$cn;
}
@@ -91,3 +108,4 @@
close(LOG);
}
}
+