# Require fails when requiring scripts with utf-8 filenames

**URL:** <https://www.ruby-forum.com/t/require-fails-when-requiring-scripts-with-utf-8-filenames/190075>\
**Category:** Ruby\
**Created:** [June 13, 2010, 2:20am UTC](https://www.ruby-forum.com/t/require-fails-when-requiring-scripts-with-utf-8-filenames/190075 "2010-06-13T02:20:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![winsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a698b9/32.png) [@winsmith](https://www.ruby-forum.com/u/winsmith)\
**Post date:** [June 13, 2010, 2:20am UTC](https://www.ruby-forum.com/t/require-fails-when-requiring-scripts-with-utf-8-filenames/190075/1 "2010-06-13T02:20:47Z")

</div>

Hi, I have a small problem with requiring files with utf-8 character in  
the filename.  
I have a small script which does nothing but require another file that  
has some norwegian utf-8 characters in its filename.

shouldnt this work nicely?

My enviroment is:  
mac os x 10.6.3  
ruby-1.9.1-p378

locale is set to:  
LANG=“en\_US.UTF-8”  
LC\_COLLATE=“en\_US.UTF-8”  
LC\_CTYPE=“UTF-8”  
LC\_MESSAGES=“en\_US.UTF-8”  
LC\_MONETARY=“en\_US.UTF-8”  
LC\_NUMERIC=“en\_US.UTF-8”  
LC\_TIME=“en\_US.UTF-8”  
LC\_ALL=

Textmate is set to utf-8.  
puts **ENCODING** says UTF-8:  
hmm. everything seems to be set correctly but when I try require  
“Ã¸lÃ¸lÃ¸lÃ¸lÃ¸l” it fails with:

ruby-1.9.1-p378 \> require “Ã¸lÃ¸lÃ¸lÃ¸l”  
Encoding::CompatibilityError: incompatible character encodings: UTF-8  
and US-ASCII  
from (irb):1:in `require' from (irb):1 from /usr/local/rvm/rubies/ruby-1.9.1-p378/bin/irb:17:in`’

and Ã¸lÃ¸lÃ¸lÃ¸l.rb is simple:

# encoding: utf-8

puts “Ã¸lÃ¸lÃ¸lÃ¸l”

Any suggestions? isnt utf-8 filenames supported? surely it must be?  
thanx!

---

<div class="post-metadata">

**Author:** ![winsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a698b9/32.png) [@winsmith](https://www.ruby-forum.com/u/winsmith)\
**Post date:** [June 13, 2010, 8:21pm UTC](https://www.ruby-forum.com/t/require-fails-when-requiring-scripts-with-utf-8-filenames/190075/2 "2010-06-13T20:21:06Z")

</div>

Tried 1.9.2 preview3 and it works!

But still no solution found for 1.9.1…

---

<div class="post-metadata">

**Author:** ![winsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a698b9/32.png) [@winsmith](https://www.ruby-forum.com/u/winsmith)\
**Post date:** [June 13, 2010, 11:14pm UTC](https://www.ruby-forum.com/t/require-fails-when-requiring-scripts-with-utf-8-filenames/190075/3 "2010-06-13T23:14:36Z")

</div>

Daniel Jonson wrote:

> Any suggestions? isnt utf-8 filenames supported? surely it must be?

Who knows? If you can find an official spec for how Strings work in ruby  
1.9, I’d love to see it. So far what I’ve managed to reverse-engineer  
I’ve documented here:

> <https://github.com/candlerb/string19/blob/master/string19.rb>

How ‘require’ is influenced by string encoding I’ve not tested. It seems  
to me the logical thing would be to treat filenames as just strings of  
bytes (as the OS does), but as I say, who knows.

---

<div class="post-metadata">

**Author:** ![winsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a698b9/32.png) [@winsmith](https://www.ruby-forum.com/u/winsmith)\
**Post date:** [June 17, 2010, 4:27pm UTC](https://www.ruby-forum.com/t/require-fails-when-requiring-scripts-with-utf-8-filenames/190075/4 "2010-06-17T16:27:00Z")

</div>

Bill K. wrote:

> 1.9.1 has barely any support for Unicode paths  
> on Windows.

Sorry… Just noticed this isn’t relevant to your  
platform.

---

<div class="post-metadata">

**Author:** ![winsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a698b9/32.png) [@winsmith](https://www.ruby-forum.com/u/winsmith)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/require-fails-when-requiring-scripts-with-utf-8-filenames/190075/5 "2010-06-17T16:22:45Z")

</div>

Daniel Jonson wrote:

> Tried 1.9.2 preview3 and it works!
> 
> But still no solution found for 1.9.1…

1.9.1 has barely any support for Unicode paths  
on Windows.

1.9.2 is much improved, although not 100% (for  
example Dir.chdir accepts UTF-8 paths, but Dir.pwd  
cannot return UTF-8 paths. It’s not clear whether  
this will be fixed before the final release.)

Regards,

Bill
