require fails when requiring scripts with utf-8 filenames.

D

Daniel Jonson

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 `<main>'

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!
 
D

Daniel Jonson

Tried 1.9.2 preview3 and it works!

But still no solution found for 1.9.1.....
 
B

Bill Kelly

Daniel said:
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
 
B

Brian Candler

Daniel said:
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:
http://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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top