You said:
How can be sure that their encoding is 'iso-8859-7' since we dont know what encoding style windows use to save filenames? How we know for example if the encoding wasnt 'cp1253' or 'utf8'?
Dude, I thought you already knew this -- I was just repeating information that I found in your original post at the top of this thread. This is the line in the OP that led me to make that statement:
Encode::from_to($_, 'ISO-8859-7', 'utf8') for @display_files;

So you tell me: how can you be sure that the file name encoding is iso-8859-7 on your machine? If you don't know, then you have problems that I probably cannot help you solve.

And also can something that its native some encoding be read as another encoding?

A stream of bytes representing character data can be read as if it were anything at all -- it's just a stream of bytes -- but it's only going to make sense if it is interpreted correctly, according to the intended character encoding.

it seemed the correct thing to believe in

So your problem boils down to a tendency towards "faith-based programming". Learn to be a skeptic.

You need to focus on the advice about doing an experiment. I wanted to make sure that this would work, so I've done the experiment already, and now you can try this yourself to see if it works for you. (It works for me.)

#!/usr/bin/perl -T use strict; use CGI; use Encode; my $c = new CGI; my @menu_choices = ( "\x{03a6}\x{03a5}", "\x{03b2}\x{03c1}" ); binmode STDOUT, ":utf8"; print $c->header, $c->start_html; print $c->h3("(Display should be readable as utf8)"), $c->h3("\x{0395}\x{03c0}\x{03ad}\x{03bb}\x{03b5}\x{03be}\x{03b5} +"); if ( $c->param( 'select' )) { # use bytes; # my $val = $c->param('select'); my $val = decode( 'utf8', $c->param( 'select' )); my $match = ( grep /^$val$/, @menu_choices ) ? "matches" : "fails +to match"; printf "<P>The value %s received from the form has length %d, and +%s.</P>", $val, length( $val ), $match; } print $c->start_form, $c->popup_menu( -name => 'select', -values => \@menu_choices ), $c->submit( 'ok' ); $c->end_form; print $c->end_html; exit;
If I comment out the "use Encode" and the line with the "decode()" call, and also uncomment the other two lines ("use bytes" and the simpler assignment to $val), it reports a failure to match, and I'm not sure why that doesn't work. (BTW, I'm using Perl 5.8.8, built for macosx 10.5)

I also tried $c->start_html( -encoding => 'UTF-8') instead of the default html header, and that did not cause my Safari browser's "default" setting for encoding to do the right thing -- it seems I have to set this browser explicitly for any non-Latin-1 character set. This leads me to suggest that it's a good idea to include a clearly visible ASCII string in your page display, telling the viewers what character encoding they should be using in their browsers, as demonstrated in my test script.

(I know there should be a way to tell the browser how to do the right thing automatically, and I can't wait to learn about that...)

update: Found it (duh!):

print $cgi->header(-charset => 'utf-8'), $cgi->start_html;
works with both Safari and Firefox. Presumably, if you really wanted to use iso-8859-7 instead of utf8 on your web pages, you set the "-charset" property for the http header accordingly. But I think you're better off working with utf8.

In reply to Re^7: somethign wrong with the sumbit by graff
in thread somethign wrong with the sumbit by Nik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.