Windows, Dir class and special characters

Discussion in 'Ruby' started by Peter John, Jun 21, 2010.

  1. Peter John

    Peter John Guest

    Hi,

    I'm using ruby 1.9.1 on windows 7 x64. If I manually make a few test
    files that have Polish characters in their names, e.g. testżłś.txt, and
    then use the Dir class to get a directory listing, I find that the
    incoming encoding is Windows-1252 and that the filenames have lost their
    special characters - e.g. it would look like testzls.txt inside ruby.

    I've spent the larger part of the day reading up on all the encoding
    stuff in 1.9.1, tried things like

    # encoding: utf-8

    and so on with no success. How do I get into ruby the filenames that
    show up in windows with Polish, Chinese, or Russian characters? Would be
    even better to find a method that works universally on Windows / Mac /
    Linux platforms.
    --
    Posted via http://www.ruby-forum.com/.
     
    Peter John, Jun 21, 2010
    #1
    1. Advertising

  2. Peter John wrote:
    > I'm using ruby 1.9.1 on windows 7 x64. If I manually make a few test
    > files that have Polish characters in their names, e.g. testżłś.txt, and
    > then use the Dir class to get a directory listing, I find that the
    > incoming encoding is Windows-1252 and that the filenames have lost their
    > special characters - e.g. it would look like testzls.txt inside ruby.


    People have reported that 1.9.2 is better in this area, so you could
    give that a go. Unfortunately 1.9.2 isn't released yet, but there's a
    1.9.2-preview3 you could try, and report back on.

    Alternatively, switch to ruby 1.8.7 where you don't have to deal with
    this encoding business at all, and your filenames will be returned to
    you as pristine and unmangled byte strings.

    --
    Posted via http://www.ruby-forum.com/.
     
    Brian Candler, Jun 21, 2010
    #2
    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. Stefan Mueller
    Replies:
    3
    Views:
    33,222
    Stefan Mueller
    Jul 23, 2006
  2. Jason Stacy
    Replies:
    0
    Views:
    344
    Jason Stacy
    May 12, 2007
  3. Replies:
    2
    Views:
    1,130
    Ingo Menger
    May 31, 2007
  4. rvino
    Replies:
    0
    Views:
    4,696
    rvino
    Aug 14, 2007
  5. majna
    Replies:
    4
    Views:
    740
    Thomas 'PointedEars' Lahn
    Sep 19, 2007
Loading...

Share This Page