Because windows are unable of saving greek filenames also in utf8 format(they save only the file contents iam afraid) i ahev to do this tediouts tranformation encodign task very often and in several instanced of my code. In the abbove example i transform grom greek => utf8 the fialen string so thay can appear correctly in the cleints browser and also then when the cleint select something uppon submit i have to *also* tranfrom back the encoded string from utf8 => greek because as you can see immediately after the user selected file must be opened.my @files = <../data/text/*.txt>; my @display_files = map /([^\/]+)\.txt/, @files; Encode::from_to($_, "ISO-8859-7", "utf8") for @display_files; print br; print start_form( action=>'index.pl' ); print h1( {class=>'lime'}, "Επέλεξ&# +949; το κείμενο π&# +959;υ σε ενδιαφέ	 +61;ει => ", popup_menu( -name=>'select', -values=> +\@display_files ), submit('Εμφάν +ιση')); print end_form; my $passage = param('select') || "Αρχική + Σελίδα!"; Encode::from_to($passage, "utf8", "ISO-8859-7") if param(); if ( param('select') ) { open(FILE, "<../data/text/$passage.txt") or die $!; .....
#date its like this because mysql needs it to be in thsi specific outline in order to insert the date into its database date field. #as for display_date this not only needs steaming but also need encoding to utf8 form otherwise in my index.pl iam not able to see the date correctly(only the number) all other date strigns to question marks.use POSIX qw(strftime); use Encode; print header( -charset=>'utf8' ); print start_html( -style=>'/data/css/style.css', -title=>'Ψυχωφελ& +#942; Πνευματικά &# +922;είμενα!' ); my ($select, $row, $data); my $date = strftime('%y-%m-%d %H:%M:%S', localtime); my $display_date = strftime('%a %d %b, %I:%M %p', localtime); Encode::from_to($display_date, 'ISO-8859-7', 'utf8'); my $host = gethostbyaddr (pack ("C4", split (/\./, $ENV{'REMOTE_ADDR'} +)), 2) || $ENV{REMOTE_ADDR}; $host = "Νίκος" if ( ($host =~ /dell/) or ($h +ost =~ /dsldevice/) or ($host =~ /localhost/) );
In reply to Re^2: Encoding problems
by Nik
in thread Encoding problems
by Nik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |