# Windows, Dir class and special characters

**URL:** <https://www.ruby-forum.com/t/windows-dir-class-and-special-characters/190464>\
**Category:** Ruby\
**Created:** [June 21, 2010, 2:39am UTC](https://www.ruby-forum.com/t/windows-dir-class-and-special-characters/190464 "2010-06-21T02:39:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweetpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@sweetpete](https://www.ruby-forum.com/u/sweetpete)\
**Post date:** [June 21, 2010, 2:39am UTC](https://www.ruby-forum.com/t/windows-dir-class-and-special-characters/190464/1 "2010-06-21T02:39:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sweetpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@sweetpete](https://www.ruby-forum.com/u/sweetpete)\
**Post date:** [June 21, 2010, 11:07am UTC](https://www.ruby-forum.com/t/windows-dir-class-and-special-characters/190464/2 "2010-06-21T11:07:46Z")

</div>

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.
