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

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. =?Utf-8?B?Sm9l?=

    Extract filename from a filename typed by user

    =?Utf-8?B?Sm9l?=, Aug 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,224
    Travis Murray
    Aug 24, 2004
  2. zhouhaiming
    Replies:
    0
    Views:
    426
    zhouhaiming
    Nov 5, 2003
  3. zhouhaiming
    Replies:
    2
    Views:
    567
    Alan Balmer
    Nov 5, 2003
  4. Replies:
    4
    Views:
    4,640
    santosh
    Oct 5, 2007
  5. Peter Otten
    Replies:
    10
    Views:
    1,009
    Nobody
    Dec 2, 2010
  6. Stefano Crocco
    Replies:
    0
    Views:
    245
    Stefano Crocco
    Nov 14, 2008
  7. iMelody Ooo
    Replies:
    5
    Views:
    688
    Charles Calvert
    Oct 21, 2010
  8. Grant Curell

    Non-Hard Coded File.open(newFile)

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