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!
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:
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.
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.)