Encoding transformation problems

Discussion in 'Perl Misc' started by Îίκος, May 27, 2006.

  1. Well finally my aproach was that:

    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'}, "Επέλεξε το κείμενο
    που σε ενδιαφέÏει => ",
    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 $!;


    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. This become even more tedious when i try to also convert other
    greek text to utf8 othweriwse it will not appear correctly.look this
    for example:

    print header( -charset=>'utf8' );
    print start_html( -style=>'/data/css/style.css',
    -title=>'Ψυχωφελή Πνευματικά
    Κείμενα!' );

    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');

    #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.

    Today i saw that another elementt of my script needs transormation to
    uft8. This has become a very bery tedious and annoying work to do and i
    ahve to repeat thsi to other scripts as well.

    I would be very gratefull if you guys find a way that i will get rid of
    theose tranformation and all page contect be default inputs and output
    as utf8.

    Thank you and sorry fot the repost but i didnt got an answe to this one.
    Îίκος, May 27, 2006
    #1
    1. Advertising

  2. Îίκος

    Matt Garrish Guest

    "?????" <> wrote in message
    news:...
    >


    > 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');
    >
    > #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.


    If you're just putting the current date and time into a database, use the
    now() function in your sql statement.

    http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

    Matt
    Matt Garrish, May 27, 2006
    #2
    1. Advertising

  3. Îίκος

    Dr.Ruud Guest

    ????? schreef:

    > Because windows are unable of saving greek filenames also in utf8
    > format


    Which version of "windows" do you refer to?

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, May 27, 2006
    #3
  4. Îίκος

    Nicky Guest

    Windows XP SP2

    When i create a new file i select to be saved as UTF8 and it does saved
    this way but only the content. The filename itself for some reason its
    nos saved in UTF8 butrather in another encoding becauae if it did greek
    filenames strings would have been displayed properly in the popup menu
    and it would saved me a lot of trouble encoding them back and forth.

    But unfortunately they dont :(
    Nicky, May 27, 2006
    #4
  5. Îίκος

    Dr.Ruud Guest

    Nicky schreef:

    Please quote the right amount of context when replying.

    > [Windows XP SP2]


    >> Because windows are unable of saving greek filenames also
    >> in utf8 format


    Windows has no real problems in that area (NT and followups, not 9x).


    > The filename itself for some
    > reason its nos saved in UTF8 butrather in another encoding becauae if
    > it did greek filenames strings would have been displayed properly in
    > the popup menu


    Are the names OK in Window Explorer?

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, May 27, 2006
    #5
  6. Îίκος

    Nicky Guest

    Dr.Ruud wrote:
    > Nicky schreef:
    > > The filename itself for some
    > > reason its nos saved in UTF8 butrather in another encoding becauae if
    > > it did greek filenames strings would have been displayed properly in
    > > the popup menu

    >
    > Are the names OK in Window Explorer?


    Yeap. they appear in nperfectly normal Greek.
    But if windows doesnt have problem saving then in UTF8 how do you
    explain the fact that in side opoup menu they appear mutilated?
    Nicky, May 27, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,839
    Jon Skeet [C# MVP]
    Jun 9, 2004
  2. Pablo
    Replies:
    1
    Views:
    401
    Joris Gillis
    Jan 28, 2005
  3. Bilal
    Replies:
    7
    Views:
    711
    Bilal
    Sep 27, 2006
  4. bizt
    Replies:
    2
    Views:
    545
    Joseph J. Kesselman
    Jul 11, 2008
  5. N. Demos
    Replies:
    0
    Views:
    90
    N. Demos
    May 13, 2005
Loading...

Share This Page