Language environment in perl; how to open a file with filename coded in IBM850

Discussion in 'Perl Misc' started by phallk, Jan 3, 2005.

  1. phallk

    phallk Guest

    Hi,

    any character-set guru out there who can assist me???

    I am accessing my Windows-XP-filesystem with samba from my Linux
    machine. This works fine as long as there are no Swedish characters in
    the filenames but becomes slightly complex (for me at least) when
    international characters starts to pop up in the filenames. It seems
    like ibm850 encoding is used because doing a "ls" as below works fine:

    use encoding "Latin-1";
    use open IO => ":encoding(ibm850)"
    open (LS,"ls --show-control-chars /mnt/e|") or die $!;
    while ($_=<LS>) {
    chomp;
    print "Fname: /mnt/e/".$_;
    }

    When reading the directory as above all filenames are displayed
    correctly with international characters. But now to my problem:

    How do I open a file. Assume the correct filename is stored in $_:

    open (FILE,$_);

    ....will not work as the filename is encoded in UTF8.

    This is probably simple, but I have spent quite some time on this.
    Thanks in advance.

    /Per Hallkvist
     
    phallk, Jan 3, 2005
    #1
    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. zhouhaiming
    Replies:
    0
    Views:
    345
    zhouhaiming
    Nov 5, 2003
  2. Peter Otten
    Replies:
    0
    Views:
    424
    Peter Otten
    Nov 30, 2010
  3. Peter Otten
    Replies:
    10
    Views:
    876
    Nobody
    Dec 2, 2010
  4. Dan Stromberg
    Replies:
    0
    Views:
    930
    Dan Stromberg
    Dec 6, 2010
  5. Grant Curell

    Non-Hard Coded File.open(newFile)

    Grant Curell, Oct 23, 2010, in forum: Ruby
    Replies:
    5
    Views:
    141
    w_a_x_man
    Oct 23, 2010
Loading...

Share This Page